迷失的幻想

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
测试Javacript里的checkbox是否被选中的status和checked的替换方法,checkbox.checked和checkbox.status的功能一样,注意checkbox.status后面接的是==
1
<html> 2 <head> 3 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 4 <title></title> 5 <script language="JavaScript"> 6 7 function check(){ 8 var checkbox = document.getElementById('test');// 9 alert(checkbox.checked);//是否被选中 10 //if(checkbox.checked){ 11 //alert("选中了"); 12 if(checkbox.status==true){ 13 alert("选中了"); 14 }else{ 15 alert("没选中"); 16 } 17 } 18 19 </script> 20 </head> 21 <body> 22 <form> 23 <input type="checkbox" id="test" /> 24 <button onclick='check()'>test</button> 25 </form> 26 27 28 </body> 29 </html>

 

posted on 2016-11-29 10:10  迷失的幻想  阅读(423)  评论(0编辑  收藏  举报