2. Inspiration
✦ Simon Willison’s getElementsBySelector
✦ Dean Edwards’ cssQuery
✦ Dean Edwards’ addEvent
✦ Prototype
✦ Behavior
✦ moo.fx
4. The Beginning
✦ Started August of ’05
✦ http://ejohn.org/blog/selectors-in-javascript/
✦ $(’#foo ol li’)
.set(’title’,’List Items!’)
.bind(’click’,function(){alert(’Hello!’);})
.select(’.tmp’)
.style(’color’,’white’)
.select(’.foo’)
.style(’background’,’red’);
✦ jSelect!
6. First Implementation
✦
function sort(f) {
cur = cur.sort(function(a,b){
if ( typeof f == ‘object’ )
var ret = f(a,b);
else
var ret = genericSort(a,b,f);
if ( a < b )
b.parentNode.insertBefore( a, b );
else if ( a > b )
a.parentNode.insertBefore( b, a );
return ret;
});
return this;
}
function reverse() {
cur[0].parentNode.appendChild( cur[0] );
for ( var i = 1; i < cur.length; i++ )
cur[i-1].parentNode.insertBefore( cur[i], cur[i-1] );
cur = cur.reverse();
return this;
}
7. Expression Parsing
✦ var t = “[title]”;
var re = new RegExp( “^[([a-z0-9-]+)(~?^?=?)’?([^’]*)’?]”, “i” );
var m = re.exec(t);
t = t.replace( re, “” );
alert( t + “---” + m[1] + “---” + m[2] );
8. Release!
✦ Released at BarCamp NYC (Jan 2006)
✦ “New Wave JavaScript”
✦ Hit Digg and del.icio.us/popular
✦ CSS + XPath
✦ DOM Modification
✦ Events
✦ moo.fx-rewrite Animations
11. First Plugin
✦ 11 days later...
✦ JSON plugin
✦ “Unlike Prototype, jQuery doesn’t mess
around with built-in JavaScript objects. It’s
new—too new to have a version number!—
but I’ve been writing some code with it
and enjoying it.”
✦ http://mg.to/2006/01/25/json-for-jquery
12. Initial Choices
✦ The “$” war
✦ .style
✦ .onclick
✦ $(“id”) -> DOMElement
DOMElement.onclick = jQuery method
✦ Creative Commons -> MIT
✦ No Ajax! -> Ajax!