时间:2021-07-27 08:19:16 | 栏目:JavaScript代码 | 点击:次
实例如下所示:
<!DOCTYPE HTML> <html> <head> <title></title> </head> <body> <ul> <li><input type="checkbox" name="ss" onclick="choose(this)">1</li> <li><input type="checkbox" name="ss" onclick="choose(this)">2</li> <li><input type="checkbox" name="ss" onclick="choose(this)">3</li> <li><input type="checkbox" name="ss" onclick="choose(this)">4</li> <li><input type="checkbox" name="ss" onclick="choose(this)">5</li> </ul> <script language="JavaScript"> function choose(obj){ var ss= document.getElementsByName("ss"); for (var i = 0; i < ss.length; i++) { ss[i].checked = false; } obj.checked = true; } </script> </body> </html>