2010-12-27 10 views
2
I "엄마 JQuery와 사람, 그리고 프로토 타입 지금 머리에 저를 걷어차는

프로토 타입 클래스 클리어 입력

내가 여기에 입력 필드,있어

:.

<input type="text" value="" name="options[3]" class="input-text required-entry product-custom-option" id="options_3_text" onchange="opConfig.reloadPrice()">` 

이 프로토 타입 스크립트를 :

function clearInput(){ 
    Form.Element.clear('options_3_text') 
    Field.clear('options_3_text') 
    $('options_3_text').clear() 
} 

onclick="clearInput();"을 설정하는 버튼

.

내가 t으로 INPUT을 좀하고 싶습니다

그는 ID options_3_text보다는 .input-text를 분류한다. 신분증이나 더 나은 방법보다는 클래스를 얻는 데 도움이된다면 환상적 일 것입니다!

답변

2

두 개의 달러 기호를 사용하여 CSS로 요소를 가져옵니다. 이 일을해야처럼 뭔가 (테스트하지!) : 당신이 그것을 필요로하는 경우에

$$('.input-text').each(function(e){ $(e).clear(); }.bind(this)); 
또한

http://www.prototypejs.org/api/utility/dollar-dollar

는 각각의 구현은 여기에서 찾을 수 있습니다 : 그것은 수 있다면 http://www.prototypejs.org/api/enumerable/each

+0

내가 당신을 키스 것이다. 정말 고맙습니다. – Tom

+0

하하, 끝내. 다행히 도울 수있다. :-) – wajiw