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

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

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

asp.net mvc - breakpoint on javascript in CSHTML? -