I am trying to add the contents of each span along with the value in the title attribute.
<div id="group-wrap" class="group"> <span class="lbracket" title="&f">(</span> <span class="grouptitle" title="&f"> Group </span> <span class="rbracket" title="&f">) </span> <span class="username" title="&f"> Username </span> <span class="col" title="&f">:</span> <span class="text" title="&f"> Helo There! </span> </div>
Here is what I still have:
var str = []; $('#group-wrap span').each(function(){ str.push($(this).attr('title')); }); alert(str.join('')); });
http://jsfiddle.net/B9QeK/3/
The output is &f&f&f&f&f (the value of each attribute of the header), but the expected result matters plus the content in the gap. The attribute value must be added before the content.
&f(&fGroup&f)&fUsername: &f text
How can I get this result?
source share