且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用 jQuery (IE) 删除禁用属性

更新时间:2023-12-05 12:46:16

您应该使用 jQuery 中的 .prop 方法,因为它会为您绕过这些烦人的 IE 错误进行完整性检查.我可以看到您正在使用 jQuery 1.6,所以这应该可以工作:

You should use the .prop method in jQuery as it does sanity checking for you bypassing these annoying IE errors. I can see you're using jQuery 1.6, so this should work:

$('document').ready(function () {
    //get each input that is disabled
    $('input').each(function(i, el){
      //see if it should be disabled (true|false)
      var disabled = $(el).data('disabled');
      $(el).prop('disabled', disabled);
    });
});

这是更新后的jsFiddle供您查看.