Working with hasClass() attribute in jQuery?

vishalneeraj-24503
Posted by vishalneeraj-24503 under jQuery category on | Points: 40 | Views : 1100
.hasClass() attribute determines whether class is assigned to any particular control or not.It returns true if any class is applied otherwise returns false.
For Example:-
<div id = "div_employee" class="class1 class2"></div>
$("#div_employee").hasClass("class1");
$("#div_employee").hasClass("class2");

Above code will return true as div has applied 2 classes as class1 and class2 in it.
$("#div_employee").hasClass("class3");

Above code will return false as there is no class3 class applied to div.

Comments or Responses

Login to post response