removeAttr()

Sniper removeAttr() method

As its name implies, the removeAttr() method is used to remove attributes from the element. This method is used to remove the specified attribute from the selected element.

Syntax

$(selector).removeAttr(attribute,...)

This method requires a mandatory parameter, which is defined as follows.

attribute: It is the required parameter that specifies one or more attributes to remove from the element. We have to separate the attribute names with space if we have to remove multiple attributes.

Let's see some examples of using the removeAttr() method.

$(".myButton").removeAttr("name","id","disabled"); 
// this will remove the name,id and disabled attributes from the button

Remove a single attribute

$(".myButton").removeAttr("disabled"); 
// this will remove the disabled attribute from the button

Last updated