여러개의 클래스에서 선택된 요소의 index() 가 같은 값이 나 올 경우
아래 html 경우 버튼의 index() 을 얻고 싶은데 0 만나옴,,
이유는 같은 <div> 안에 형제 관계가 아니기 때문임
<div class=”d-flex w-100″>
<div><button type=”button” class=”_btnCustom btn w-50″ >btn1</button></div>
<div><button type=”button” class=”_btnCustom btn w-50″ >btn1</button></div>
<div><button type=”button” class=”_btnCustom btn w-50″ >btn1</button></div>
</div>
$(function(){
$(“._btnCustom”).click(function()
{
alert($(this).index());
{
alert($(this).index());
})
})
아래와 같이 같은 div 안에 함께 있어야 원하는 index 조건이 성립됨
1개의 요소 div 안에 같은 형제 button
<div class=”d-flex w-100″>
<div>
<button type=”button” class=”_btnCustom btn w-50″ >btn1</button>
<button type=”button” class=”_btnCustom btn w-50″ >btn1</button>
</div>
<button type=”button” class=”_btnCustom btn w-50″ >btn1</button>
<button type=”button” class=”_btnCustom btn w-50″ >btn1</button>
</div>
</div>




Views Today : 54
Views Yesterday : 36
Views This Month : 297
Views This Year : 20953
Total views : 79571
Who's Online : 1