jQuery removeAttr() method

The jQuery removeAttr() method remove an attribute from each element in the set of matched elements.

Source Code

<!DOCTYPE html>
  <script src="http://code.jquery.com/jquery-latest.js"></script>
 	 .highlight { border : 2px solid #1E8CBE; }
<div class="div1" title="Hello World!!!">Div 1</div>
<div class="div2">Div 2</div>

<button id="button">Get Attribute Value</button>
jQuery("button").click(function () {
	var val = jQuery(".div1").removeAttr("title");
	jQuery(".div2").text("title attribute removed from div1");


Following example removes the “title” attribute from div1 (having div1 class1) and adds highlight class on it.

Div 1
Div 2


No comments yet.

Leave a Reply