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 ...

Get jQuery and JavaScript Phrasebook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.