if a == "http://foo.bar"
and $(b[0]).attr("href") == "http://foo.bar"
then why does the following code not return true:
$("[href^=\"" + a + "\"]", b).length > 0
?
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.
Because the second parameter passed to the jQuery function scopes the selector, which is to say, find the selected element in the children of b.
So by way of an example
This will return 1
This will return 0
Live example: http://jsfiddle.net/mkudf/
Based on your comments, it seems you’re doing some stuff before adding the element to the dom, so by example:
I can find no way of achieving what you want (The above to alert “1”) without wrapping the dynamic elements in an extra element:
Which shouldnt be too much of a problem, when adding to the dom you could just take
$x.children():