HTML:
....<span id="elem_id0" style="....color:blue...">some text</span>
....<span id="elem_id1" style="....color:blue...">some text</span>
....<span id="elem_id2" style="....color:black...">some different text</span>
....<span id="elem_id3" style="....color:blue...">some text</span>
...
I am changing the color dynamically using javascript. at the ned of it all, I want to have a count of all elements whose id began with elem_id” and color is “blue”.
I am trying following. (tried many variations). total is coming up right, but blue count is always coming 0. dont know why….
var blues = $('#[id^="elem_id"][font-color="blue"]').length;
var total = $('#[id^="elem_id"]').length;
Pl advice.
****UPDATE*******
removed the previous update. The failure was due to typo in adding attr (added with a white space before color). and hence it failed when matching (no white space here…).
I have fixed my mistake all good now.
thx to all.
Try this instead:
jsfiddle example