Looking at this
get value of inside a tag with jQuery.?
<span>
<b>hi_1</b>
<b>hi_2</b>
<b>hi_3</b>
<b>hi_4</b>
<span>
where the question was to get a comma delimited string of the tag contents
the solution is a push inside an each.
Is there a shorter (and possibly faster) way using for example
$("span b").text().join(",") which of course does not work since text() does not return an array…
UPDATE:
the “bug report” (feature request) posted by artyom had this rather interesting snippet
var x = $("span b").map(function() {
return $(this).text();
}).toArray().join(", ");
which is similar to BrokenGlass’ solution but shorter…
http://jsfiddle.net/mplungjan/M42Qx/
I prefer the toArray one…
You could use map(), but I doubt this would be faster since you have to convert from jQuery object to array and back to jQuery object:
jsFiddle link