Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting jQuery attribute for font-weight

Tags:

jquery

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?

like image 959
JennyM Avatar asked Jun 17 '11 08:06

JennyM


3 Answers

use the .css() function instead of .attr()

$("#opt_" + i).css("font-weight", "bold")
like image 105
Alo Avatar answered Oct 09 '22 14:10

Alo


It's not an attribute, but CSS:

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

example: http://jsfiddle.net/niklasvh/ENwbn/

like image 36
Niklas Avatar answered Oct 09 '22 14:10

Niklas


$("#opt_" + i).style("font-weight", "bold");
like image 31
devmatt Avatar answered Oct 09 '22 15:10

devmatt