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

 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.οnlοad=function(){
11             var style1=document.getElementById('style1');
12             var shu=document.getElementById('shu');
13             var button1=document.getElementById('button1');
14             
15             button1.οnclick=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>

 

转载于:https://www.cnblogs.com/hduhdc/p/5250875.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值