how to get content of all <li> tags in one page using jquery
问题 I have an html list something like this: <li id="tag">red</li> <li id="tag">yellow</li> <li id="tag">blue</li> How can I get the content of these li tags using jQuery? For example; $tags = red, yellow, blue 回答1: You can use jQuery.map() Live Demo texts = $('li').map(function(){ return $(this).text(); }).get().join(','); 回答2: var $tags = $("li").map(function(){ return $(this).text(); }).get().join(","); Here, have a fiddle: http://jsfiddle.net/KTted/2/ 回答3: First, you should change your id=