Andreas
Andreas

Reputation: 621

find a element with certain name in a js variable filled by a jquery query

I can search the dom with .find('.dbfieldname') to find all elements from the class dbname. I also can save the result as an object in a variable like that: myelems = .find(...

But I can't search in my object for certain elements using find(). I tried the following:

my.find(*[name=versionnumber])

How can I do that right ?

Upvotes: 0

Views: 440

Answers (2)

rkw
rkw

Reputation: 7297

Your logic is fine, my is already a jQuery object, so my.find() would normally work.

The problem is that .find() searches for childrens. What you want is my.filter('[name="' +versionnumber+ '"]');

Upvotes: 4

J0HN
J0HN

Reputation: 26941

jQuery(my).find("*[name=versionnumber]")

Btw, better use jQuery.find() or $.find() rather than just .find(), it makes code at least more readable.

Upvotes: 0

Related Questions