Remove an attribute from each element in the set of matched elements.
// <a href="#" target="_blank">Link</a>
$('a').removeAttr('target');
<a href="#">Link</a>
// <img src="..." width="100" height="100">
$('img').removeAttr('width height');
<img src="...">
$('a').removeAttr(function(index, el) {
// 'this' and 'el' refer to the same DOM element
return el.id === 'special' ? 'target' : 'href';
});
// Removes 'target' from links with id="special"
// Removes 'href' from all other links
| Parameter | Type | Description |
|---|---|---|
| name | string | function | A string (space-separated) of attributes to remove, or a function that returns such a string. The function is called for each element with arguments (index, element). |
Returns: The original SR object for chaining.