미채택 완료

스크립트질문입니다.

2019-12-19 (목) 17:47:50 2,257

jQuery에 있는  $(this).index(); 라는 함수가 javascript에는 없나요? ㅠ

아무리 검색해도 안나오네용..

Copy
<div class="parent">
    <select onchange="ch();">
        <option value="">a</option>
        <option value="">a</option>
    </select>
</div>
<div class="parent">
    <select onchange="ch();">
        <option value="">a</option>
        <option value="">a</option>
    </select>
</div>

이런 상태에서 select박스에 onchange 함수를 작동시키면 그 부모인 .parent의 index 값을 얻어야 하는데.. 도무지 모르겠습니다.. 도움좀 부탁드립니다.

|

답변 1개

document.getElementById("mySelect").selectedIndex = "2"; 

참고하세요.

답변을 작성하려면 로그인이 필요합니다.