I can select a node using jQuery with something like $('#element_id')
but how would I get the DOM element for use with non-jQuery functions that expect something like would be returned by document.getElementById()
?
views:
520answers:
3
+10
A:
You can retrieve DOM elements using array notation:
$("#element_id")[0]
or with get()
:
$("#element_id").get(0)
cletus
2010-02-23 04:59:49
Works perfectly, thank you :) I was looking through the jQuery API but I wasn't quite sure what to look for. All I found was `.context`.
Mark
2010-02-23 05:07:55
A:
$('#element_id') and document.getElementById() both returns the same object. even jquery calls the document.getElementbyId internally. if u can explain that is non-jQuery fn, then i could suggest some thing.
coder
2010-02-23 05:00:20
The jQuery function returns a jQuery object and not raw DOM objects.
leo-the-manic
2010-02-23 05:02:09