Modifying the DOM element properties

We can use jQuery to dynamically modify element properties such as class, style, and disabled, which means that it is possible to visually alter and change the function of a range of HTML elements.

Getting ready

Once again, this recipe requires an additional blank HTML document. Create a file named recipe-5.html, and have it open and ready for editing.

How to do it…

Learn how to alter the properties of the DOM element by performing each of the following steps:

  1. Add the following HTML code to your blank recipe-5.html file in order to create a basic HTML page with two types of inputs:
    <!DOCTYPE html> <html> <head> <title>Modifying DOM element attributes and properties</title> <script src="jquery.min.js"></script> <script> ...

Get jQuery 2.0 Development Cookbook 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.