간단한 jQuery 질문입니다.

간단한 jQuery 질문입니다.

QA

간단한 jQuery 질문입니다.

답변 2

본문


<button id = "reset" type="button"> 원위치</button>
 
<p>
<select class="clas">
  <option>1</option>
  <option>2</option>
  <option>3</option>
  <option>4</option>
  <option>5</option>
  <option>6</option>
  <option>7</option>
</select>
</p>

 
<p>
  <select class="clas">
    <option>1</option>
    <option>2</option>
    <option>3</option>
    <option>4</option>
    <option>5</option>
    <option>6</option>
    <option>7</option>
  </select>
  </p>

 
<script>
  $('#reset').click(function () {
    $(".clas option:eq(0)").prop("selected", true);
    
    // 초기화
}); 

 

셀렉트 박스의 옵션이 초기화 되는 제이쿼리 함수인데요, 이상하게 같은 클래스인데도 하나만 동작하고

나머진 가만히 있습니다.

모든 클래스에 적용가능하게 할 수 있을까요?

이 질문에 댓글 쓰기 :

답변 2

$('#reset').click(function () {
  $(".clas").prop('selectedIndex', 0);
});

답변을 작성하시기 전에 로그인 해주세요.
QA 내용 검색
질문등록
전체 0
© SIRSOFT
현재 페이지 제일 처음으로