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

Popular posts from this blog

php - Passing multiple values in a url using checkbox -

compilation - PHP install fails on Ubuntu 14 (make: *** [sapi/cli/php] Error 1) PHP 5.6.20 -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -