Home  >  Article  >  Web Front-end  >  Detailed explanation of the second parameter of jQuery() method_jquery

Detailed explanation of the second parameter of jQuery() method_jquery

WBOY
WBOYOriginal
2016-05-16 16:01:41976browse

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")

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.

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