首页 > Web开发 > 详细

通过js来修改div的style(background,border,。。。。。。。)

时间:2016-03-07 16:38:42      阅读:211      评论:0      收藏:0      [点我收藏+]
 1 <!DOCTYPE HTML>
 2 <html>
 3     <head>
 4         <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
 5         <title>无标题文档</title>
 6         <style>
 7         #div{width:100px;height:200px;border:2px solid red;background:blue;}
 8         </style>
 9         <script>
10         window.onload=function(){
11             var style1=document.getElementById(style1);
12             var shu=document.getElementById(shu);
13             var button1=document.getElementById(button1);
14             
15             button1.onclick=function(){
16             div.style[style1.value]=shu.value;
17             };
18         };
19         </script>
20     </head>
21     <body>
22         请输入样式:<input id="style1" type="text" value=""/><br/>
23         请输入数据:<input id="shu" type="text" value=""/>
24         <input id="button1" type="button" value="button"/>
25         <div id="div"></div>
26 
27     </body>
28 
29 
30 
31 
32 
33 </html>

 

通过js来修改div的style(background,border,。。。。。。。)

原文:http://www.cnblogs.com/hduhdc/p/5250875.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!