Home  >  Article  >  Web Front-end  >  The second parameter of the jQuery function gets the DOM element in the specified context_jquery

The second parameter of the jQuery function gets the DOM element in the specified context_jquery

WBOY
WBOYOriginal
2016-05-16 16:47:531253browse

The second parameter of the jQuery function can specify the search range of DOM elements.

The second parameter can be divided into the following types

DOM reference
jQuery wrapper
document

Code example

Copy code The code is as follows:














< ;input name="" type="button"/>











Summary

The different types of the second parameter, the corresponding usage is as shown in the table below.
类型 用法
jQuery wrapper <font face="NSimsun">$('input', $('form')).length</font>
DOM reference <font face="NSimsun">$('input', document.forms[0]).length</font>
document <font face="NSimsun">$('input', 'body').length</font>
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