Home > Web Front-end > JS Tutorial > body text

Detailed explanation of the second parameter of jQuery() method_jquery

WBOY
Release: 2016-05-16 16:01:41
Original
1011 people have browsed it

Regarding the second parameter of the jQuery() method, there are the following usages:

1.jQuery(selector, [context])

This usage is equivalent to $(context).find(selector) or context.find(selector)

2.jQuery(html, [ownerDocument])

The document’s explanation of ownerDocument is: “Create the document where the DOM element is located”

In other words, if you want to write scripts for document, such as iframe or open a new window using window.open, you may need it

3.jQuery(html, props)

This should be more commonly used, just paste the code directly:

$("<input>", {

 type: "text",

 val: "Test",

 focusin: function() {

  $(this).addClass("active");

 },

 focusout: function() {

  $(this).removeClass("active");

 }

}).appendTo("form")

Copy after login

That is to say, the attributes in props will be set to the newly created tag like the .attr() method

The above is the entire content of this article, I hope you all like it.

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!