I'm a beginner in JQuery,
How can I get the control as a javascript object from a JQuery object
var _object = $(this). ??
The Document Object Model (DOM) elements are something like a DIV, HTML, BODY element on the HTML page. A jQuery Selector is used to select one or more HTML elements using jQuery. Mostly we use Selectors for accessing the DOM elements.
The jQuery selector finds particular DOM element(s) and wraps them with jQuery object. For example, document. getElementById() in the JavaScript will return DOM object whereas $('#id') will return jQuery object.
If you have a variable containing a DOM element, and want to select elements related to that DOM element, simply wrap it in a jQuery object. var myDomElement = document. getElementById( "foo" ); // A plain DOM element. $( myDomElement ).
The Document Object Model (DOM for short) is a representation of an HTML document. It may contain any number of DOM elements. At a high level, a DOM element can be thought of as a "piece" of a web page. It may contain text and/or other DOM elements.
Most common
var _object = $(this)[0];
If you have more than 1 elements matched: $(this)[0]
, $(this)[1]
, $(this)[2]
and so on.
$(this).get()
is also possible. It's only advantage over the array model is that it allows selection of the kind $(this).get(-1)
where it gets you the last matched object
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With