What is the equivalent of document.getElementbyId in JQuery?
javascript, jquery
Solution
`.get(index)`
$('#map_canvas').get(0)
$('#map_canvas')[0]
Though, `document.getElementById` obviously has better performance - it is the method used internally by the jQuery core when querying the DOM for a single ID selector.
So then you're building a jQuery object just to discard it afterwards. Up to you whether to save some bytes in the bandwidth or microseconds in execution time.
Not much difference, honestly. I use the jQuery version when performance is not concerned and I'm lazy to type `document.getElementById`, though vanilla JS is a bit more logical in this case.
Problem
``` map = new google.maps.Map(document.getElementById('map_canvas'), mapOptions); ``` But this does not work: ``` map = new google.maps.Map($('#map_canvas'), mapOptions); ``` I am looking for something like... ``` $('#map_canvas').toElementBlahblah? ```