Removing $() jQuery wrapper to just get raw JS element

javascript, jquery

Solution

var firstElem = $(element)[0];

or

var firstElem = $(element).get(0);

Calling `get()` without an index gives you an array of the elements.

Reference: jQuery get()

Problem

Random just out of curiosity question: Let's say for whatever reason I get an element back from a function ``` $(element) ``` But I want to remove the $( __ ) jQuery wrapper to leave the regular DOM Element: ``` element ``` Is this possible? (I'm sure it'd be smart to test `$(element).length()` to make sure it isn't more than 1 thing inside beforehand too... jsFiddle

Original source

Related problems