Read 02: jQuery, Events, and The DOM - Ahmad-Sawalqeh/amman-301d1 GitHub Wiki
JQuery
jQuery is a javascript file that you include in your web page. It lets you find elements using CSS-style selectors and then do something with the elements using jQuery methods.
- SELECT ELEMENTS:
$('li.hot')JQuery Object. - PERFORM TASKS:
$('li.hot').addClass('complete');method - HANDLE EVENTS:
jQuery's motto is "Write less, do more," because it allows you to achieve the same goals but in fewer lines of code than you would need to write with plain JavaScript.
DOING THINGS WITH YOUR SELECTION:
-
Content filters:
.html(),text(),replaceWith(),remove().before(),after(),append(),empty,add().attr(),removeAttr(),removeClass(),css(),addClass().val(),isNumeric(). -
Finding/Inserting elements:
find(),parent(),children(),siblings(),next(),prev().eq(),lt(),gt(). -
Dimension/Position:
height(),width(),innerHeight(),innerWidth(),outerHeight(),outerWidth(). -
Effects & Animation:
show(),hide(),toggle(),fadeIn(),fadeOut(),fadeToggle(),animate(). -
Events:
ready(),load(),on().
Checking a page is ready to work with:
jQuery's .ready() method that the page is ready for your code to work with.
$(document).ready(function(){
// Your script goes here
});
// OR
$(function(){
// Your script goes here
});