Jquery: Javascript That Doesn'T Suck!
Jquery: Javascript That Doesn'T Suck!
Presented By
Mir Nazim
www.mirnazim.com
[email protected]
WHAT and WHEN
John Resig - www.ejohn.org
Released at BarCamp NYC on Jan
2006
jQuery 1.0 out on Aug 2006
version 1.1.3 latest
~ 800% faster for DOM processing
numerous other improvements
WHY
Doesn’t mess with the language
(Prototype)
Great community
Tons of plugins
GENRAL PURPOSE
ABSTRACTION LAYER
FOR
COMMON
WEB SCRIPTING
TASKS
What's Good in it
$('td:contains("Henry")').siblings()
$('td:contains("Henry")').parent().find('td:gt(0)')
$('td:contains("Henry")').parent().find('td')
.not(':contains("Henry")') )
$('td:contains("Henry")').parent().find('td:eq(1)')
Method Chaining
//get every cell containing "Henry"
$('td:contains("Henry")')
//get its parent
.parent()
//find inside the parent the 2nd cell
.find('td:eq(1)')
//add the "highlight" class to that cell
.addClass(highlight')
//revert back to the parent of the cell containing "Henry"
.end()
//find inside the parent the 3rd cell
.find('td:eq(2)')
//add the "highlight" class to that cell
.addClass('highlight');
Events
$('#some-element').bind('click',function() {
$('body').addClass('large');
//some more stuff
//even some more stuff
});
//eq of some-input.value
$('input').val()
$('#some-button').click(function() {
$('#some-div').load('a.html');
});
AJAX + JSON
$('#some-button').click(function() {
$.getJSON('b.json');
});
Take action on data
$('#some-button').click(function() {
$.getJSON('b.json', function(data) {
// do some stuff with data you just go
});
Execute a script
$('#some-button').click(function() {
$.getScript('c.js');
});
Load other data formats
$('#some-button').click(function() {
$.get('my-format.data', function(data) {
//handle your data way you want
});
});
A GET request
$.get('e.php',
{'term': $(this).text()},
function(data) {
$('#some-div').html(data);
}
);
POST request
$.post('e.php',
{'term': $(this).text()},
function(data) {
$('#some-div').html(data);
}
);
AJAX observers
$('#loading').ajaxStart(function() {
$(this).show();
}).ajaxStop(function() {
$(this).hide();
});
There is more
http://jquery.com/plugins
http://doc.jquery.com/Plugins
Resources
http://doc.jquery.com
www.visualjquery.com
www.Google.com
15 days of jQuery (blog)
Learning jQuery (blog)
Thanks A Millions
? QEUSTIONS