I'd like to use a single method in jQuery to set both text colour and text itself, as in the hypothetical / failing method:
$("#north_america_stat").css({
color : northAmericaColour,
text: northAmerica
});
The "text: northAmerica" is not working.
I understand it's possible to set them individually like this:
$("#north_america_stat").text(northAmerica);
then:
$("#north_america_stat").css({
color : northAmericaColour,
});
but in the interest of tight code I'd like to combine the methods into one - is this possible?
$('#north_america_stat').css({color: northAmericaColour}).text(northAmerica);?textis not a css property, so I'm not sure why you're trying to do this. Use method chaining instead.