views:

289

answers:

1

Hi,

I have a javascript object called 'element' of type HTMLInputElement that corresponds to a HTML input text box element on my page. (Thus, something like $F('element') using prototype will return the text of this box). Is there a way, using prototype and this 'element', for me to access the value of the next HTML input text box in the DOM after 'element'?

Thanks!

+2  A: 

You can use Element.next with a CSS rule:

$('element').next('input[type=text]');
CMS
This one works only if the input elements are on the same level (they are siblings) but not for the whole DOM
Andris
Yes, I assumed that he was looking for the next `input` sibling, but if it's not the case the OP should post some markup...
CMS
Sorry about that; I should have mentioned that my elements were not siblings. Thanks, CMS, for your answer. I was able to use it in conjunction with 'down' to get what I was looking for: $F(element.next('div').down('input[type=text]'))
nedblorf