안녕하세요! 나는 의심 스럽다. 이드를 통해 요소를 가져와야합니다. 나는 document.getElementById() 또는 jquery selector를 사용할 수 있지만 jquery 나 다른 라이브러리를 사용하고 싶지는 않다는 것을 알고있다. 아이디어는 js와 라이브러리가없는 컴포넌트를 만드는 것입니다. 그래서id로 요소 가져 오기
<div id="objprop">
<div id="prop-header"><span>Mi Ventana</span></div>
<div id="prop_width" style="clear: both;">
<label style="margin-left: 7px; margin-bottom: 7px; float: left;">Width</label>
<input type="text" style="float: right; margin-right: 7px; width: 70px;" id="width">
</div>
<div id="prop_height" style="clear: both;">
<label style="margin-left: 7px; margin-bottom: 7px; float: left;">Height</label>
<input type="text" style="float: right; margin-right: 7px; width: 70px;" id="height">
</div>
<div id="prop_left" style="clear: both;">
<label style="margin-left: 7px; margin-bottom: 7px; float: left;">Left</label>
<input type="text" style="float: right; margin-right: 7px; width: 70px;" id="left">
</div>
<div id="prop_top" style="clear: both;">
<label style="margin-left: 7px; margin-bottom: 7px; float: left;">Top</label>
<input type="text" style="float: right; margin-right: 7px; width: 70px;" id="top">
</div>
</div>
, 난에 입력 폭 ID 값을 설정하려면 supose하자
나는이 상황, 코드에 의해 생성 된 코드를 얻었다. document.getElementById는 html에있는 동일한 id를 가진 다른 요소 일 수 있으므로 사용에 대해서는 확실하지 않습니다. 내 의심
이것은 질문입니다. 뭘 물어 보는 거냐? 동일한 ID를 가진 DOM에 둘 이상의 요소가있을 수 있는지 여부 – Zach
@Zach 페이지 코더가 "id"값이 고유해야한다는 것을 모르는 경우 :-) – Pointy
감사합니다. 그럼 내 실수;) –