Methods to Modify Content

We use several jQuery methods to modify our HTML content as we work through the projects in this book.

hide, show, and toggle

The hide and show methods make it easy to hide and show user-interface elements. We can hide one or many elements on a page, like this:

jqueryprimer/simple_selection.html
 
$(​"h1"​).hide();

We use the hide method throughout this book to hide page sections that need to appear only when JavaScript is disabled, such as transcripts or other fallback content. To show elements, we simply call the show method instead.

We can use toggle to easily toggle the visibility of an element.

If the jQuery function found several items that matched the selector, all of those items would be shown, hidden, or toggled. ...

Get HTML5 and CSS3, 2nd Edition 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.