api.jquery.com
api.jquery.com copied to clipboard
'Selector' type ambiguous
From the Types page:
If Selector is specified as the type of an argument, it accepts everything that the jQuery constructor accepts, eg. Strings, Elements, Lists of Elements.
The jQuery constructor accepts Selector
, Element
, Array
, PlainObject
, and jQuery
.
The definitions are conflicting. Does Selector
really mean String
when it's used throughout documentation or is the selector
argument supposed to be of type String
instead of Selector
?
A Selector
string is a specific type of string that is a valid CSS selector. Note that the jQuery constructor also accepts other strings that represent HTML markup, which we distinguish by how they "look".
What it's saying is that you can pass either a selector string or an element itself, for example jQuery("body")
, jQuery(document.body)
, and jQuery([ document.body ])
all get you the same collection. However, jQuery("<body>")
is not the same thing, it's creating a <body>
element, not selecting the <body>
element in the current document.
Thank you for the response. I actually wanted to emphasize the part from the Types page.
If
Selector
is specified as the type of an argument, it accepts everything that the jQuery constructor accepts, eg. Strings, Elements, Lists of Elements.
After looking over a decent portion of the documentation, it seems that Selector
will never refer to Elements
or Lists of Elements
. I believe that that part of the Types page is incorrect.
Can you suggest some wording that would clarify it?
Removing that specific paragraph would be good. The rest of the text describes Selector
well and is consistent with how Selector
is used throughout the rest of the documentation.
Yep, I agree.
Hey @leonard-thieu did you mean to close this? We should leave the ticket open until the change is made.