What does $find('mycontrol') do that jquery’s $('#mycontrol') doesn’t?
How are they different?
Sorry, I’m a JS novice.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The first is invalid unless you defined a function named
$find, and the selector is missing its#if theid-selector[docs] is intended.If you mean:
vs
Then:
the first searches from within the context of the elements matched by
$('.someSelector')the second searches the entire document.
Because you’re trying to get an element by ID, you might as well use the second version because there can only be one on the page anyway (IDs must be unique), and selecting by ID is generally very fast.
If
#mycontrolshould only be fetched if it happens to descend from some other selector, you could use the second version, but this would be a rare case I would think.