xmr_chenx
xmr_chenx
2016-06-21 08:23

javascript中,为什么在IE上全选按钮不能正常执行,而在火狐上可以运行?求大神解答,急!

 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>按钮(期末)</title>
<script>
    function all()
    {
        var checkboxs = document.getElementsByName("email");
        for(var i = 0; i < checkboxs.length; i++)
            checkboxs[i].checked = true;
    }
    function allNo()
    {
        var checkboxs = document.getElementsByName("email");
        for(var i = 0; i < checkboxs.length; i++)
            checkboxs[i].checked = false;
    }
    function contrary()
    {
        var checkboxs = document.getElementsByName("email");
        for(var i = 0; i < checkboxs.length; i++)
        {
            if(checkboxs[i].checked == true)
                checkboxs[i].checked = false;
            else
                checkboxs[i].checked = true;
        }
    }
</script>
</head>
<body>
<input type="checkbox" name="email" id=""/>第一封信<br/>
<input type="checkbox" name="email" id=""/>第二封信<br/>
<input type="checkbox" name="email" id=""/>第三封信<br/>
<input type="checkbox" name="email" id=""/>第四封信<br/>
<input type="checkbox" name="email" id=""/>第五封信<br/>
<input type="button" value="全不选" onclick="allNo();"/>
<input type="button" value="反选" onclick="contrary();"/>
<input type="button" value="全选" onclick="all();"/>
</body>
</html>
  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

2条回答