removeAttr() not removing “disabled” attribute in IE

前端 未结 3 895
后悔当初
后悔当初 2020-12-03 07:17
var disableSelection = function(){
    $(\"#elementId\").attr(\"disabled\",\"disabled\");    
};

var enableSelection = function(){
    $(\"#elementId\").removeAttr(         


        
3条回答
  •  悲哀的现实
    2020-12-03 07:58

    Jquery Docs says, about .removeProp():

    Note: Do not use this method to remove native properties such as checked, >disabled, or selected. This will remove the property completely and, once >removed, cannot be added again to element. Use .prop() to set these properties >to false instead.

    Additional Notes:

    In Internet Explorer prior to version 9, using .prop() to set a DOM element >property to anything other than a simple primitive value (number, string, or >boolean) can cause memory leaks if the property is not removed (using >.removeProp()) before the DOM element is removed from the document. To safely >set values on DOM objects without memory leaks, use .data().

提交回复
热议问题