I was reviewing code and found that
$("#item1 #item2") and $("#item1>#item2")
are used interchangeably. Is there any difference or is it one and the same?
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.
Both will match
But only the first one will match
The first expression uses the descendant selector. The
>symbol in the second expression is the child selector. Both are standard CSS selectors.However, since
ids must be unique, both are overcomplicated. Instead, you should just use$('#item2')