javascript .each() 클릭 관련 질문있습니다. 채택완료
경하귀요밍
8년 전
조회 4,014
예를들어
</p><p><style></p><p>.b{display:none;}</p><p></style></p><p><div class="a">1</div></p><p style="margin-left: 40px;"><div class="b">a</div></p><p style="font-size: 14.6667px;"><div class="a">1</div></p><p style="margin-left: 40px; font-size: 14.6667px;"><div class="b">a</div></p><p style="font-size: 14.6667px;"><div class="a">1</div></p><p style="margin-left: 40px; font-size: 14.6667px;"><div class="b">a</div></p><p style="font-size: 14.6667px;"><div class="a">1</div></p><p style="margin-left: 40px; font-size: 14.6667px;"><div class="b">a</div></p><p style="font-size: 14.6667px;"><div class="a">1</div></p><p style="margin-left: 40px; font-size: 14.6667px;"><div class="b">a</div></p><p style="margin-left: 40px; font-size: 14.6667px;">
이렇게 div가 구성되어있고, 첫번째 ".a" div 를 클릭하면 첫번째 ".b" div 가 보여지고 다시 클릭하면 hide 되는 스크립트를 짜려하는데
</p><p style="margin-left: 40px; font-size: 14.6667px;"><script></p><p style="margin-left: 40px;"><span style="font-size: 14.6667px;">$(document).ready(function(){</span></p><p style="margin-left: 40px;"><span style="font-size: 14.6667px;"><span class="Apple-tab-span" style="white-space:pre"> </span>$('.a').each(function(i){</span></p><p style="margin-left: 40px;"><span style="font-size: 14.6667px;"><span class="Apple-tab-span" style="white-space:pre"> </span>$(this).click(function(e){</span></p><p style="margin-left: 40px;"><span style="font-size: 14.6667px;"><span class="Apple-tab-span" style="white-space:pre"> </span>$('.b').each(function(j){</span></p><p style="margin-left: 40px;"><span style="font-size: 14.6667px;"><span class="Apple-tab-span" style="white-space:pre"> </span>$(this).eq(i).toggle(function(f){});</span></p><p style="margin-left: 40px;"><span style="font-size: 14.6667px;"><span class="Apple-tab-span" style="white-space:pre"> </span>});</span></p><p style="margin-left: 40px;"><span style="font-size: 14.6667px;"><span class="Apple-tab-span" style="white-space:pre"> </span>});</span></p><p style="margin-left: 40px;"><span style="font-size: 14.6667px;"><span class="Apple-tab-span" style="white-space:pre"> </span>});</span></p><p style="margin-left: 40px;"><span style="font-size: 14.6667px;">});</script></span> </p><p style="margin-left: 40px; font-size: 14.6667px;">
이렇게 하니까 반응이 없더라구요..
어떤식으로 수정해야하는지.. 부탁드립니다.
댓글을 작성하려면 로그인이 필요합니다.
답변 1개
답변을 작성하려면 로그인이 필요합니다.
로그인
$(document).ready(function(){
$('.faq_q').each(function(i){
$(this).click(function(e){
$('.faq_a').eq(i).toggle('fast');
});
});
});
[/code]
자체 해결했습니당!! 감사합니다!!