JQuery and dom objects in javascript, jquerydom
1. a dom object belongs to the Document Object Model, while a Query object encapsulates one or more dom objects. Therefore, dom objects can be considered as one entity, jQuery looks at the collection of multiple dom objects.
2. jQuery and dom do not contain or are contained. Therefore, jQuery objects cannot call dom methods or attributes. Similarly, dom,
{($ ("# Swap"). innerHTML = "embedded text"
GetElementById ("wrap" ).html ('embedded text ')
.
3. jQuery and dom objects can be converted to each other. Because of this, a common method is to capture an object through dom and then archive it as a jQuery object, the reason is that the jQuery object does not need to be traversed when no operation is required.
4. jQuery object and dom object Conversion Method
Convert jQuery to a dom object
{
Var $ li = $ ("li ");
Var li = $ li [0];
Li. innerHTML;
}
{
Var $ li = $ ("li ");
Var li = $ li. get (0); // call the domget Method
Alert (li. innerHTML );
}
Convert a dom object to a jQuery object
{
Var li = getElementById ('lil'); // obtain all li Elements
Var $ li = $ (li); // encapsulate the obtained li element into a jQuery object.
Alert($li.html ());
}