0

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 ?

2
  • This is missing so much information. What is my for starters? Commented Aug 9, 2011 at 7:48
  • my is a javascript array, which holds all the elements found by the following jquery query: my = $('input') Commented Aug 9, 2011 at 8:08

2 Answers 2

4

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+ '"]');

Sign up to request clarification or add additional context in comments.

2 Comments

The following worked fine: my.filter('[name="' +versionnumber+ '"]'); But I'm not sure if my really is a object - I think it is an ordinary js array, because I can reach the elements by my[index]. Thank you very much.
Actually, I'm not really sure how it's stored. I'm going to ask SO if it's not already asked. All I know is you can retrieve the HTML elements using my[index]; but if you wanted to retrieve them as jQuery objects, you can use my.eq(index).
0
jQuery(my).find("*[name=versionnumber]")

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

2 Comments

thanks, but this doesn't work as well. I tried: jQuery(my).find("") jQuery(my).find("*[name=database]") $(my).find("*[name=database]") don't know why - I can get elements like that: *my[0].name but then I would have to loop through all elements two times.
Well, what is "my"? It should be a jQuery object or DOM node. If it is some hand-made JS-object you cant use jQuery on it

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.