Manipulating element CSS
jQuery allows developers to access the CSS properties of DOM elements directly. This provides an easy way to alter the look and feel of your application based on data within your JavaScript. This recipe will show you how to manipulate DOM CSS in various elements.
Getting ready
You are going to need three files for this recipe. Using your editor of choice, create recipe-1.html
, recipe-1.js
, and recipe-1.css
in the same directory as the latest version of the jQuery library.
How to do it…
Of the three files you have just created, open each one for editing and perform the following steps:
Add the following HTML code to
recipe-1.html
; be sure to change the source location of the JavaScript included for the jQuery library, pointing it to where the latest version of jQuery is downloaded on your computer:<!DOCTYPE html> <html> <head> <title>Chapter 6 :: Recipe 1</title> <link href="recipe-1.css" rel="stylesheet" type="text/css...