Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert jQuery element to a regular dom element

Tags:

A regular dom element is such as:

document.getElementById('a')

or

document.createElement('div')

But jQuery returns elements in another format, so for instance I'd like to convert what is returned by $('#a') to the same result as what is returned by document.getElementById('a')

Is this possible using jQuery?

thanks

like image 336
zjm1126 Avatar asked Mar 14 '10 07:03

zjm1126


2 Answers

You can reference the DOM element with .get(0) or [0], eg $('#foo')[0] assuming there is just one.

like image 196
meder omuraliev Avatar answered Sep 22 '22 12:09

meder omuraliev


$('#a')[0] 

// oops my answer is too short

like image 44
Anantha Kumaran Avatar answered Sep 21 '22 12:09

Anantha Kumaran