jQuery Basics

Objectives

Selecting with jQuery

First we must select the element/s

$("selectorGoesHere")

Manipulating Style

Then we manipulate

the .css() method is jQuery's interface to styling.

$(selector).css(property, value)

Example - This will select the h1 tag, and change the css color to yellow

$("h1").css("color", "yellow");

Select element with id "special" and give it a red border

$("#special").css("border", "2px solid red");

We can also pass in an object with styles var styles = { backgroundColor : "pink:, fontWeight: "bold" }; $("#special").css(styles);