I got a jquery script that counts words and adjusting the font-size based on the amount of words. The problem is that it counts all the attributes with h1 in the parent. I want it to count individually for each h1. The originally script is marked as h1:first. Here is the script where it counts all h1 in the class wofa:
$(function(){
var $quote = $(".wofa h1");
var $numWords = $quote.text().split(" ").length;
if (($numWords >= 1) && ($numWords < 3)) {
$quote.css("font-size", "1px");
}
else if (($numWords >= 3) && ($numWords < 6)) {
$quote.css("font-size", "5px");
}
else if (($numWords >= 20) && ($numWords < 30)) {
$quote.css("font-size", "10x");
}
else if (($numWords >= 30) && ($numWords < 40)) {
$quote.css("font-size", "15px");
}
else {
$quote.css("font-size", "1px");
}
});
I tried the .each() method with your selector and nothing was selected.
I ended using $(‘.wofa, h1).each():
Here’s a working version on jsfiddle:
http://jsfiddle.net/russianator/jKPdQ/