Syntax of jQuery

We use a $ within our script section to indicate that we are accessing the jQuery library. Let's compare the syntax for one instruction between regular JavaScript and jQuery-enhanced JavaScript.

Regular JS: document.getElementById("sampleId").innerHTML = "Hello AHS!";

jQuery: $("#sampleId").html("Hello AHS!");

To select all <p> tags you would use $("p").

To change contents of an iframe $("iframe").attr("src","http://www.apple.com");

To change styling, $("#sampleId").css("backg", "400px");

To change styling of a class, $(".sampleClass").css("backg", "400px");

To detect a click, $("#id").click function() {...};

Let's work through some of the examples on the site.