<html> <head> <title>石家庄水刀切割</title> </head> <body> <SELECT onChange="changebg(this)"> <OPTION SELECTED>没有背景 <OPTION VALUE="url('/images/20130704/bgdemo1.jpg')">雪花背景 <OPTION VALUE="url('/images/20130704/bgdemo2.jpg')"> 纹理背景 <OPTION VALUE="url('/images/20130704/bgdemo3.jpg')"> 方格背景 </select> </body> </html> <script language=javascript> function changebg(obj){ selindex=obj.selectedIndex //取得选定选项的序号 bgsrc=obj.options[selindex].value //取得背景图片的路径 document.body.style.background=bgsrc //设定style.background属性,改变页面背景 } </script> <br />
转载于:https://www.cnblogs.com/youtianxia/p/3867418.html