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

论坛 期权论坛 脚本     
匿名技术用户   2020-12-30 04:09   385   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.ο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

分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:7942463
帖子:1588486
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP