Full documentation of jQuery can be found at jQuery.com
//local
//on the web
//should be placed with pther referenced scripts
$('#button1').click(
function(){
console.log('1 Clicked!');
}
)
$(document).ready(function() {
//anything from anywhere in the code
})
$(function {
//anything from anywhere in the code
})
Which means: $(function(){}) can be written everywhere
Nevertheless, the best practive is to write all js and jQery code in the end of the body of the page
$( "#myId" ); //a selector by Id
$( ".myClass"); //a selector by class
$( "input[name='firstName']"); //input by it's name
$( "#contents ul.people li"); //ul with class people somewhere under a selector with id contents
$( ":button"); //all types of buttons (both input and button)
$( "form :input"); //all types of input fields in a form
$( "div.head").length //number of div selectors in the page with class head
$( "div.head" ).has("p"); //div in class head with p selector inside
$( "h1" ).not(".bar"); //h1 element that does not have bar class
$( "ul li").filter( ".current"); //list without class current
$( "ul li").first(); //the first item of a list
$( "ul li").eq( 5 ); //the sixth element in a list
$('#addBorder').click (
function() {
$('#toBeChanged').addClass('bordered');
}
)
$('#removeBorder').click (
function() {
$('#toBeChanged').removeClass('bordered');
}
)
//the above example uses hover and mouse out with multiple css classes
$('#toggler').click (
function(){
$('#txtToggled').toggleClass('redBorder');
}
)
Affected by the buttons
'slow' , 'medium' and 'fast' or time in milliseconds will determin the speed of the action
back to main page