Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert jquery element to html element

I have a jQuery element but I have to send it to a function that only accepts HTML elements. How can I convert the jQuery element to an HTML element?

like image 225
Freesnöw Avatar asked Aug 18 '11 22:08

Freesnöw


People also ask

How do I get HTML using jQuery?

To get HTML content of an element using jQuery, use the html() method. The html() method gets the html contents of the first matched element.

How do I pull a native DOM element from a jQuery object?

Use the get() method. However, most of the time you want to use jQuery methods to do the manipulation as opposed to getting access to the raw DOM element and then modifying it using "standard" JavaScript. For example, with jQuery you can just say $('mySelector'). addClass('myClass') to add a CSS class to a DOM element.

What is $() in jQuery?

$() = window. jQuery() $()/jQuery() is a selector function that selects DOM elements. Most of the time you will need to start with $() function. It is advisable to use jQuery after DOM is loaded fully.

How HTML elements are used in jQuery with example?

The html() method in jQuery is used to get the contents of the first element in the set of matched elements or is used to set the HTML contents of every matched element. It returns the content of the first matched element. This function does not accept any arguments.


1 Answers

Try myJQueryElement.get(0) or myJQueryElement[0]. (get() is most useful when you need negative indices, for example, as described in the documentation for get().)

like image 50
jtbandes Avatar answered Oct 08 '22 04:10

jtbandes