开发者

Changing CSS attribute with JQuery

Today I was shown a really simple way to change the font-size of an element using jQuery. It looked very similar to the following:

<script  type="text/javascript">
    jQuery(document.body) ({font-size:5em;});
</script>

This obviously doesn'开发者_如何学Ct work, but I was wondering what's missing? I remember it being just one line of code.

Note: I have tried jQuery(document.body).css({font-size:5em;}); as well, without success.

Thanks.


jQuery('body').css({fontSize:'5em'});


$('body').css('font-size', '5em'); 

Should work.


Quote key names and values in JavaScript object literals, and separate them with commas, don't terminate them with semi-colons.

{
    "font-size": "5em"
}


How about:

<script  type="text/javascript">
$("body").css("font-size","70%");
</script>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜