A repository of over 1000 quality jQuery plugins

jQuery .removeAttr()

Learn all about the jQuery function .removeAttr().

The .removeAttr() method uses the JavaScript removeAttribute() function, but it has the advantage of being able to be called directly on a jQuery object and it accounts for different attribute naming across browsers.

Note: Removing an inline onclick event handler using .removeAttr() doesn’t achieve the desired effect in Internet Explorer 6, 7, or 8. To avoid potential problems, use .prop() instead:

1
2
$element.prop( "onclick", null );
console.log( "onclick property: ", $element[ 0 ].onclick );