Howto create own Jquery Like Function in Javascript?

Posted by streetparade on Stack Overflow See other posts from Stack Overflow or by streetparade
Published on 2010-04-25T20:17:35Z Indexed on 2010/04/25 20:23 UTC
Read the original article Hit count: 100

Filed under:

How can i create a function which looks like the jquery callback $

Say i want to call a element with id= "mydiv".

i want to be able to call it like

var div = $("mydiv").value;

i think the function should look like

function $(element)
{
  return  document.getElementById(element);
}

Is that the right way to do it, or do you prefer another way to solve it?

© Stack Overflow or respective owner

Related posts about JavaScript