i am using
$('<div/>').attr('font-weight','bold');
It is not applying font-weight to bold with above function. Is there something wrong in there?
i am using
$('<div/>').attr('font-weight','bold');
It is not applying font-weight to bold with above function. Is there something wrong in there?
Yea, something's wrong, the $() function is used to select an element, class or id, not a mal-formed tag. Also, you should use the css() function to change css properties so you need something like this:
$("#mydiv").css('font-weight', 'bold');
If you want to select all divs, you can do this:
$("div").css('font-weight', 'bold');
@cloudhead has answered this well, but if you want to alter multiple css properties at one time it would look like:
$("div").css({'font-weight': 'bold', 'font-size': '3em'});
Alternately, you could use jQuery's chaining method. Not as efficient, but it's a nice taste of the kind of flexibility jQuery has.
$("div").css('font-weight', 'bold').css('font-size', '3em');
I encourage you to look at the jQuery Tutorials to get a better sense of what jQuery can do.