Javascript Shorthand for getElementById

In the following sample I define a variable byId and set it to the function. You can use any valid variable name in place of byId

var byId = function( id ) { 
return document.getElementById( id ); 
};

byId( 'someID' )

With jQuery simply $('#{id}) works as well.

Author

David

comments powered by Disqus