首页 新闻 会员 周边

onchange 事件不能发生,请大家帮忙看看

0
悬赏园豆:10 [待解决问题]
 1 <!DOCTYPE html>
 2 <html lang="en">
 3 <head>
 4     <meta charset="UTF-8">
 5     <title></title>
 6     <style type="text/css">
 7         .text{height:100px;font-weight:700;
 8             width:100px;line-height:25px;
 9             text-align:center;border:1px solid black;
10             }
11     </style>
12 </head>
13 <body>
14     <p class="text">
15         helloworld!
16         helloworld!
17         helloworld!
18         helloworld!
19     </p>
20     <p class="tbn">
21         <input id="btn" type="color"/>
22     </p>
23     <script type="text/javascript">
24         var btn = document.getElementById("btn");
25         var pt = document.getElementsByClassName("text")[0];
26         btn.onchange = function(){
27             pt.style.color = this.value;
28         }
29     </script>
30 </body>
31 </html>
我爱喝绿茶的主页 我爱喝绿茶 | 初学一级 | 园豆:144
提问于:2016-08-17 20:45
< >
分享
所有回答(4)
0

可以执行的,肯定是你选择的颜色和上一次相同!

刘宏玺 | 园豆:14020 (专家六级) | 2016-08-17 21:45
0

可以执行的,我试了,你再试试

 

爱吃de馒头 | 园豆:255 (菜鸟二级) | 2016-08-17 22:04
0

实测,可以执行,我想你可能在Windows下,直接点击了确定,事实上是需要先添加到自定义颜色,然后选中自定义颜色,再点确定。。。

顾晓北 | 园豆:10844 (专家六级) | 2016-08-18 09:02
0

可以执行,IE不支持 type= "color"

jgig11 | 园豆:338 (菜鸟二级) | 2016-08-19 10:20
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册