I am looking to adjust the font size based on the value within the span element.
The numbers in the class name may vary.
Issue: using text() retrieves all values (e.g. 50020)
I want to incorporate each() and $this in some way. How can I do this?
Thank you
<span class="emo_vote-1">50</span>
<p>something.</p>
<span class="emo_vote-2">0</span>
<p>something.</p>
<span class="emo_vote-3">20</span>
jQuery
var voteNumberSpan = jQuery("span[class^=\"emo_vote\"]");
var voteNumber = voteNumberSpan.text();
//console.log(voteNumber);
if (voteNumber <= 30) {
voteNumberSpan.css("fontSize","10px")
} else if(voteNumber == 50) {
voteNumberSpan.css("fontSize","16px")
} else {
voteNumberSpan.css("fontSize","24px")
}
//I tried also:
//voteNumberSpan.each(function (i) {
//var voteNumber = voteNumberSpan.text();
//if (voteNumber < 30) {
//voteNumberSpan.css("fontSize","10px")
//} else if(voteNumber == 50) {
//voteNumberSpan.css("fontSize","16px")
//} else {
//voteNumberSpan.css("fontSize","24px")
//}
//});