checkbox disabled="false" 后执行不了点击事件? disabled状态的元素不响应点击动作 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <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> 楼主可以 自己封一个自定义事件 做mouseover + 鼠标点击监听 操作试试 只是提供一个思路,这个是可行的。<!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> 给禁用的checkbox加个标志,用脚本禁止选中吧,不设置disabled然后判断那个标志弹出ok,no即可代码相信楼主自己就可以写好 因为是想要禁止点击那种变灰的效果,所以要设置disabled当然,如果要做,自然是可以用模拟的方法来做,只是工作量会加大。5楼提供的方法,是外层来嵌套标签实现,但是事实上点击checkbox上还是没反应的,只能通过点击checkbox边缘空隙去触发事件。 在大部分浏览器disabled的form元素上的用户事件是被取消掉的,也不会把事件向上冒泡,所以根本无法得知用户是否点击了这些元素。 求一条正则表达式 extjs后台数据库中记录内容更改,如何刷新前台store上对应记录 如何判断几个层是否在一条线上 急!!!asp chat聊天室在聊天内容之间调用外部数据,请高手指教!!!附源代码 请问如何才能去处IE顶部的脚本提示 跪求一句代码 Netscape里面如何控制CSS属性display? 有关window.open()及window.print()的问题? 怎么屏蔽掉IE的关闭功能 有没有办法实现单击一个连结产生一个声音效果,比如,一个很短促的“叮”的一声。 关于IE的window对象表述正确的有 请教下这段C# 用js如何实现
<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>
然后判断那个标志弹出ok,no即可
代码相信楼主自己就可以写好
当然,如果要做,自然是可以用模拟的方法来做,只是工作量会加大。
5楼提供的方法,是外层来嵌套标签实现,但是事实上点击checkbox上还是没反应的,只能通过点击checkbox边缘空隙去触发事件。