Advanced JavaScript and Jquery-1
Advanced JavaScript and Jquery-1
jQuery
Topics
• JavaScript pseudo-classes, prototypes, and object-oriented design
• CSS manipulation
• AJAX
Basic syntax is:
$(selector).action()
A dollar sign to define jQuery
A (selector) to "query" HTML elements
A jQuery action() to be performed on the element(s)
Examples:
$(this).hide() - hides current element.
$("p").hide() - hides all paragraphs
$("p.test").hide() hides all paragraphs with - class="test“
$("#test").hide() hides the element with id="test“
Selectors
jQuery selectors allow you to select and manipulate HTML elements as a group or as a single element.
• $("tag") Element selector matches all elements with the given element name.
• $(".class") Class selector matches all elements with the given CSS class.
For example, to select the single element with id="grab" you would write: