많은 요소 (입력, 선택, 체크 박스 등)가있는 양식이 있습니다. 명시 적으로 요소별로 처리하지 않고 양식 안의 모든 요소에 동작을 적용하려면 어떻게해야합니까? [error] Threw an exception: document.myForm is undefined
양식 안의 모든 요소를 어떻게 요청할 수 있습니까?
내가이 일을 시도 : 그것은 제대로 작동
storeEval |
window.document.getElementsByTagName('form')[0].id = 'myForm';
window.document.defaultView.getComputedStyle(window.document.getElementById('myForm')).getPropertyValue('background-color');
내가 오류가
storeEval |
window.document.getElementsByTagName('form')[0].id = 'myForm';
window.document.defaultView.getComputedStyle(window.document.myForm.getElementsByTagName('*')).getPropertyValue('background-color');
| result
:
여기 (셀레늄 IDE에서) 내 코드입니다.
나는이 작업을 수행하려고
: 나는 당신이 그렇게 할 이유를 잘 모르겠지만, 모든 아이를 참조하기 위해[error] Threw an exception: document.myForm is undefined
(getComputedStyle + getPropertyValue 메서드를 사용하여) 폼의 모든 요소에 대한 배경색을 가져와야합니다. – user1211063
최상의 솔루션은 현재 수행중인 작업에 따라 달라지며 이는 분명하지 않습니다. – Simone
코드에서'document.myForm'을 참조하고 있습니다.'myForm'에'HTMLFormElement' 객체를 저장 했으므로'myForm'이어야합니다. – Simone