In regular javascript there is no #foo. The nearest (though not exact) equivalent would be document.getElementById('foo'). Something you could do along those lines would be:
Code:
var myfoo = document.getElementById('foo');
myfoo.onfocus = myfoo.onblur = function(e){
if(e.type === 'focus'){
//do this;
}else{
//do that;
}
};
But this is misleading because jQuery is assigning the events via addEventListener/attachEvent (whichever is first available), and is creating a reference to an object containing an (the first on the page if there are any) element with an id of foo regardless of whether or not that object has any members. And because one of the very reasons for using jQuery is to be able to use error reducing shortcuts of this nature unavailable in standard javascript. To do all that in standard javascript would be quite lengthy and involved.
Bookmarks