javascript - Jquery to Get attribute values of dom elements matching a class name -


i have series of html elements such as

<li id="1" class="jstree-unchecked jstree-open"> <li id="2" class="jstree-checked jstree-open"> <li id="3" class="jstree-unchecked jstree-open"> <li id="4" class="jstree-checked jstree-open"> <li id="5" class="jstree-checked jstree-open"> <li id="6" class="jstree-unchecked jstree-open"> <li id="7" class="jstree-undetermined jstree-open"> 

i want id's of elements have classname {jstree-checked or jstree-undetermined}.

i have tried using selectors, there linq way in jquery?

could please jquery like? list of id's can comma separated.

the output: "2,4,5,7"

the best way use .map() method:

var ids = $(".jstree-checked, .jstree-undetermined").map(function() {     return this.id; }).get();  console.log(ids.join());  // "2,4,5,7" 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -