0

For example > look at the code below

<div class="s1 s2 s3">
//content goes here
</div>

This class is added dynamically, so i like to know how the find the second class (say for example : "s2").

and do some action..

2
Contributors
4
Replies
8
Views
4 Years
Discussion Span
Last Post by designershiv
0

What do you undestand the word "find"? If you must to get a element which have class "s2"

$(".s2")
0

Hey radow thanks for your reply.

simply we say this "s2 class" is added dynamically, we dont know what is that. My question is how to remove the second or last class (whatever it may be) in a div

0

You can following code:

var clases = $(".s1").attr("class").split(" ");//get all classes for element with class="s1"
 var className = classes.pop();//if must remove last class
 var className = classes[1];//if must remove 2 class
 $(".s1").removeClass(className);//remove class

I hope this help.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.