jquery remove attribute code example

Example 1: remove attribute jquery

$("button").click(() => {
  $("div").removeAttr("id"); // <div id='12' class='nice'></div> --> <div class='nice'></div>
});

Example 2: assigned property delete in jquery

We can use removeAttr() to delete the assigned property of the element.

Example:
<p class="element_name" id="element_id" name="element_name">
  
js: $("p").removeAttr("name");
output: <p class="element_name" id="element_id">

Example 3: remove attribute jquery

$('p').attr('style','');