O'Reilly logo

jQuery and JavaScript Phrasebook by Brad Dayley

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Changing Fonts

$("p").on("click", function(){   $(this).css({"font-weight":"bold",        "font-style":"italic",        "font-size":22,        "font-family":"cursive, sans-serif"}); });

A fun option available using the .css() method is the ability to alter the font of paragraphs and other elements. You can use the .css() method for a variety of purposes, such as illustrating an area already read or accentuating text that becomes contextually important. You can adjust the font-weight, font-size, font-style, and font-family attributes directly to change the appearance of the text.

To programmatically alter the font values, apply the .css(property, value) or .css({property:value, property:value...}) method. The ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required