You can use jQuery removeAttr function to remove attributes from HTML element using jQuery. To do this, you need to only specify the id the HTML element. In addition to this, you also need to specify the attribute you want to remove.

Also, define the click event on which you have to remove the HTML element. You can use the button to remove the HTML element on click of it.

How to Remove Attributes From HTML Element Using jQuery

Below is the example to remove attribute on click of the button. You have to add some jQuery script and <button> element.


This is simple content inside a div element.

There is a button given above. On click of above button, the attribute getshref removed from the div. Pass the attribute as the argument of the removeAttr function which you want to remove from the HTML element.

In addition to removal o the attribute, it also removes the CSS properties specified under the style attribute for the selected HTML element.

You must also read.
How to Show/Hide Div On dropdown Selection Using JQuery
How to Show/Hide Div On Select of the Radio Button Using JQuery

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.