Setting jQuery attribute for font-weight

Viewed 24210

I am trying to change the font-weight of an element. I tried with the following but it doesn't seem to work:

$("#opt_" + i).attr("font-weight", "bold");

Also what's the difference between prop and attr? Is that something to do with my problem?

5 Answers
$('#labelAmt').css("font-weight", "bold").css("color", "firebrick");

I just gave an answer because if somebody wants to set multiple properties in a single statement.

So rather than above statement, you can set with comma separated value. Here it is syntax:

$('#labelAmt').attr({"font-weight": "bold", "data-test-2": val2}); //you can set your custom attributes too.
Related