Suppose I am using the each function on ‘myClass’
jQuery('.myClass').each(function(){
......
});
My HTML code is
<div class="myClass class2 class3 "></div>
My Question is in the above jquery Each Function i want to get the name of the class “myclass” which triggers the each function.if i use the jQuery(this).attr('class') i get the entire list of classes like “myClass class2 class3”
Thanks in advance
There is
but it will not work inside
.each().You would have to resort to a simple variable to pass the selector into the function:
After reading your comment below, you can do the following: