Home >Web Front-end >JS Tutorial >jQuery context attribute usage example_jquery

jQuery context attribute usage example_jquery

WBOY
WBOYOriginal
2016-05-16 16:24:191365browse

The example in this article describes the usage of jQuery’s context attribute. Share it with everyone for your reference. The specific analysis is as follows:

This attribute can return the original DOM node content passed to jQuery(), which is the second parameter value of the jQuery() method.
If the jQuery() method does not specify this parameter, then context points to the current document.
Grammar structure:

Copy code The code is as follows:
$("selector").context

Example code:

Example 1:

Copy code The code is as follows:






Script Home







  • Test script






By default, the original DOM node passed to jQuery() is Document, which will return [object] in IE browser and [object HTMLDocument] in other browsers.
Example 2:

Copy code The code is as follows:






Script Home







  • Test script






The return value of the above code is [object HTMLUListElement], but in IE browser it is [object]

I hope this article will be helpful to everyone’s jQuery programming.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn