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

Categories

Recent Tweets

"Setting up and Getting Started with Power BI Embedded | Data Exposed" channel9.msdn.com/Shows/Data-Exp… #webcast #feedly
Retweeted by @dyardy @scottgu @victoriabeckham Worlds collide, double take on that photo!
@scottgu @victoriabeckham Worlds collide, double take on that photo!
@projectedxyz It is really easy, what are you doing (isn't this data which on the web)