kaleazy
kaleazy

Reputation: 6232

How do you use the jQuery contains function with object variables?

I know this works:

var $object = $('*:contains("I am a simple string")');

So why doesn't this work as well?

var $object = $someObject:contains("I am a simple string");

Upvotes: 0

Views: 192

Answers (1)

Matt Ball
Matt Ball

Reputation: 359776

That's syntactically invalid JavaScript. Even if you change the : to a . in the second case, there is no .contains() method, so I think this is what you intend:

var $object = $someObject.find('*:contains("I am a simple string")');

Upvotes: 1

Related Questions