I have 5 divs.
<div class="wx-temp">89 <sup>°F</sup></div>
<div class="wx-temp">91 <sup>°F</sup></div>
<div class="wx-temp">87 <sup>°F</sup></div>
<div class="wx-temp">90 <sup>°F</sup></div>
<div class="wx-temp">89 <sup>°F</sup></div>
I get them like this.
var degress = $("div.wx-temp").text();
I want to append celcius values after the sup elements.
When I get the degress in .each function it parse the text like this:
{8,9,°,F,9,1,°,F.........}
I want to get only integers like this:
{89,91,87,90,89}
How can I do this? THANKS.
If you’re iterating over
.text, that’s what you’ll get – an iteration over each character in the string. You want to iterate over the entire list of elements:Strictly,
$(this).text()above will yield"89 °F", rather than"89", butparseIntwill take care of that.