views:

42

answers:

2

I would like to use

$("#fooid")

in place of

document.getElementById("fooid")

because I'm getting the id with the # in front of it. While you can remove it easily enough, there is a fair amount of intermixing between when I'm using a jQuery selector and when I'm using native DOM calls. In particular this is being called inside a chart draw, which seems to expect a native DOM object back. Giving it this extended jQuery object makes it choke and turn purple.

Is there a way I can get jQuery to "play nice" and pretend to give, or return instead, a native object?

+1  A: 

With .get()

David Dorward
+5  A: 

You can use the get method to get the DOM object:

$("#fooid").get(0);

Or a bit shorter version:

$("#fooid")[0];
Sarfraz
+1, additionally, `.get()` with no arguments returns an array of DOM nodes.
Skilldrick