JavaScript: jQuery
Michał Okulewicz
Warsaw University of Technology
Faculty of Mathematics and Information Science
jQuery: introduction
jQuery is a JavaScript library dedicated to easier operations on several HTML DOM elements in one function
Current version
1.x – supports IE 6, 7 and 8
2.x – does not support IE 6,7 and 8
jQuery hides browser specific functions and
jQuery: basic query
jQuery utilizes CSS selectors in $() function
$('li') instead of
document.getElementsByTagName('li')
$('ol ul li') instead of
very long plain JS code
jQuery
Applications
Applying styles/classes to all selected elements
Attaching events to all selected elements http://api.jquery.com/category/events/event-
object/
Animating selected elements
CSS styles and classes
$(selector/element).addClass(class)
$(selector/element).removeClass(class)
$(selector/element).css(style name, value)
JS events
$(selector/element).click(handler)
$(selector/element).submit(handler)
$(selector/element).keypress(handler) etc.