Jquery: The Way To Javascript and Rich Internet Applications
Jquery: The Way To Javascript and Rich Internet Applications
•Why do I want it
• Rich Internet Applications (RIA)
• Dynamic HTML (DHTML)
•How do I get it
• www.jquery.com
•How can I learn it
• jQuery in Action by Bibeault & Katz, Manning
• jQuery Visual Quickstart Guide by Holzner, Peachpit
• www.jquery.com
• docs.jquery.com
• www.visualjquery.com
• www.Jqueryfordesigners.com
• www.gscottolson.com/weblog/ - cheat sheet
• www.javascripttoolbox.com/jquery
Plan for the 4 sessions
• jQuery() = $()
• $(function) The “Ready” handler
• $(‘selector’) Element selector expression
• $(element) Specify element(s) directly
• $(‘HTML’) HTML creation
• $.function() Execute a jQuery function
• $.fn.myfunc(){} Create jQuery function
Tutorial 1 – The Ready Function
•$(‘img’).bind(‘click’,function(event){alert(‘Howdy’;});
•$(‘img’).bind(‘click’,imgclick(event));
• Allows unbinding the function
•$(‘img’).unbind(‘click’,imgclick());
•$(‘img’).unbind(‘click’);
•$(‘img’).one(‘click’,imgclick(event));
• Only works once
•$(‘img’).click(imgclick);
•$(‘img’).toggle(click1, click2);
•$(‘img’).hover(mouseover, mouseout);
Element Properties – “this”
•this
•this.id
•this.tagName
•this.attr
•this.src
•this.classname
•this.title
•this.alt
•this.value (for form elements)
‘Event’ properties
• .stopPropagation() no bubbling
• .preventDefault() no <a> link, no <form> submit
• .trigger(eventType) does not actually trigger the event, but
calls the appropriate function specified as the one tied to
the eventType
• .click(), blur(), focus(), select(), submit()
• With no parameter, invokes the event handlers, like
trigger does, for all the elements in the wrapped set
Shortcut Event Binding
• .click(func)
• .submit(func)
• .dblclick(func)
• .mouseover(func)
• .mouseout(func)
• .select(func)
Useful Event Functions
• .hide() display:true
• .show() display:none
• .toggle(func1, func2) first click calls func1, next click
executes func2
• .hover(over, out) mouseover, mouseout
AJAX
• What is AJAX
• The basic AJAX function – XMLHttpRequest
• Initiating a request
• Getting the response