首页 > 开发 > JS > 正文

如何为属性是disabled的表单绑定js事件

2017-09-05 13:02:29  来源:网友分享

一个表单,属性是disabled

<input type="text" disabled/>u200b

我希望点击该表单后,disabled变为可编辑,用了下面的代码

$(':input').click(function () {    $(this).removeAttr('disabled');})

可是发现怎么点击都不行,求指导。测试地址 http://jsfiddle.net/6cm9r/

解决方案

$(document).click(function(e){    var el = e.target;    if (el.tagName == 'INPUT') {        $(el).removeAttr('disabled');    }})