문제

My question might seem trivial but I can't find resources about selecting elements that are descendant of a given element.

I have a form in which I want all fields (they should be all the inputs and selects that are child of the form tag, except buttons) to submit the form when ENTER key is pressed. Actually I require to call a custom Javascript method to submit the form, instead of merely submitting it the plain old way.

This because I need to raise a different Stripes ActionBean event depending on the button being hit (or in the case of enter key I know what event to fire a priori).

I can apply a custom CSS class to all fields (booooooooooooring) and I can select all form fields in a page with $$('input[type!=button], select').

How to constrain the selection to elements that descend from a given form tags (which has an ID?). The selection will be used to handle the keyup event

도움이 되었습니까?

해결책

$$('input[type!=button],select', '#formid')

* selects all elements.

다른 팁

Something along the lines of

$$('#formId input[type!=button],#formId select')

Haven't been using prototype but i assume most CSS selectors work

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top