日期:2014-05-16 浏览次数:20609 次
<input type="checkbox" disabled="false">
<input type="checkbox">
<script>
var aInput = document.getElementsByTagName("input");
for(var i=0; i<aInput.length; i++){
aInput[i].onclick = function(){
if(this.getAttribute("disabled")=="false"){
alert("NO");
}else{
alert("OK");
}
}
}
</script>
<input type="checkbox" disabled="disabled">
<input type="checkbox">
<script>
var aInput= document.getElementsByTagName("input");
for(var i=0; i<aInput.length; i++){
if(aInput[i].getAttribute("disabled")== true){
alert("NO");
}else{
alert("OK");
}
}
</script>
<!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=utf-8" />
<title>无标题文档</title>
<style>
button{ background:none; border:0;}
</style>
</head>
<body>
<button><input type="checkbox" name="input" disabled="false"></button>
<button><input type="checkbox" name="input"></button>
<script>
var aInput = document.getElementsByTagName("button");
for(var i=0; i<aInput.length; i++){
aInput[i].onclick = function(){
if(this.firstChild.getAttribute("disabled")=="false"){
alert("NO");
}else{
this.firstChild.checked = "checked";;
alert("OK");
}
}
}
</script>
</body>
</html>