The second parameter of the jQuery () method, the second parameter of jquery
The second parameter of the jQuery () method has the following usage:
1. jQuery (selector, [context])
This usage is equivalent to $ (context). find (selector) or context. find (selector)
2. jQuery (html, [ownerDocument])
The document explains ownerDocument as follows: "Create the document where the DOM element is located"
That is to say, if you want to write a document script, such as iframe, or use window. open to open a new window, you may need it.
3. jQuery (html, props)
This should be more common and you can directly paste the Code:
$ ("<Input>", {type: "text", val: "Test", focusin: function () {$ (this ). addClass ("active") ;}, focusout: function () {$ (this ). removeClass ("active ");}}). appendTo ("form ")
That is to say, attributes in props will be set to the newly created tag like the. attr () method.
Note: IE cannot set the type attribute of input through. attr ().