Umesh Moghariya
Umesh Moghariya

Reputation: 3183

get specific class from a nest of <ul><li>

http://jsfiddle.net/5MSAb/1/

It has a nested <ul><li> made for jstree.

I need the the id of the li where '.jstree-checked' class in inserted.

In the jsfiddle I am just printing all the ids on the console and not searching for a specific class.

I am not able to get all the ids.

Upvotes: 0

Views: 136

Answers (3)

Umesh251
Umesh251

Reputation: 108

$('li').filter('.jstree-checked').something();

would search all the li with .jstree-checked.

Upvotes: 1

Ron
Ron

Reputation: 2790

$('li.jstree-checked').each(function() {
    console.log(this.id);
});

It will give you what you want.
I checked your mark up, by the way, it is highly unrecommended that using same ID for different objects.

Upvotes: 2

Dhaval Shukla
Dhaval Shukla

Reputation: 1127

Use Jquery wildcard operator '*' to accomplish this:

$('[class*=jstree-checked]').click(function(){
    alert(this.id);  
});

Upvotes: 0

Related Questions