Why can't I filter out an element by its id using jQuery? -
try in browser's javascript console:
$('<p><span id="wow">foobar</span></p>').filter('#wow')
what []
. why that? isn't supposed filter out span who's id isn't "wow"?
.filter()
filters set of matched elements. element in set of elements <p>
tag, doesn't match selector.
you want use .find()
instead:
> $('<p><span id="wow">foobar</span></p>').find('#wow') [<span id="wow">foobar</span>]
Comments
Post a Comment