테스트 사이트 - 개발 중인 베타 버전입니다

$('').each 이용해서 class=cate 이것만 해당 속성값 가져오는 방법 채택완료

amkorjquery 9년 전 조회 3,570

</p><p> </p><p><table id="show" width="100%" cellpadding="2" cellspacing="0" border="0"></p><p><tbody></p><p><tr></p><p><span style="font-size: 11pt; line-height: 1.5;">  <td></span></p><p>    <input type="hidden" name="no[]" value="3333"></p><p>      <span class="view"></p><p>        <input type="checkbox" name="view[3333]" checked=""></p><p>      </span></p><p>      <span class="cate">제주시</span></p><p>      <span class="sub">▶</span></p><p>  </td></p><p></tr></p><p style="font-size: 14.6667px;"><tr></p><p style="font-size: 14.6667px;"><span style="font-size: 11pt; line-height: 1.5;">  <td></span></p><p style="font-size: 14.6667px;">    <input type="hidden" name="no[]" value="2222"></p><p style="font-size: 14.6667px;">      <span class="view"></p><p style="font-size: 14.6667px;">        <input type="checkbox" name="view[2222]" checked=""></p><p style="font-size: 14.6667px;">      </span></p><p style="font-size: 14.6667px;">      <span class="cate">남제주</span></p><p style="font-size: 14.6667px;">      <span class="sub">▶</span></p><p style="font-size: 14.6667px;">  </td></p><p style="font-size: 14.6667px;"></tr></p><p style="font-size: 14.6667px;"><tr></p><p style="font-size: 14.6667px;"><span style="font-size: 11pt; line-height: 1.5;">  <td></span></p><p style="font-size: 14.6667px;">    <input type="hidden" name="no[]" value="1111"></p><p style="font-size: 14.6667px;">      <span class="view"></p><p style="font-size: 14.6667px;">        <input type="checkbox" name="view[1111]" checked=""></p><p style="font-size: 14.6667px;">      </span></p><p style="font-size: 14.6667px;">      <span class="cate">서제주</span></p><p style="font-size: 14.6667px;">      <span class="sub">▶</span></p><p style="font-size: 14.6667px;">  </td></p><p style="font-size: 14.6667px;"></tr></p><p></tbody></p><p></table></p><p> </p><p> </p><p><script type="text/javascript"></p><p><span style="font-size: 14.6667px;">var el = 'show';</span> </p><p>$('#'+el).each(function() {</p><p style="margin-left: 0px;"> var o_href = $(this).attr('class');<span class="Apple-tab-span" style="font-size: 11pt; line-height: 1.5; white-space: pre;">	</span><span style="font-size: 11pt; line-height: 1.5;">    </span></p><p style="margin-left: 0px;">});</p><p></script></p><p>

 

HTML 보시면 반복된 tr 태그가 보입니다.

 

jquery each 이벤트를 이용해서 class가 cate인 속성값만 추출하고 싶습니다.

 

그러니깐 each 이벤트 안에 console.log(); 을 찍으면

"제주시","서제주","남제주" 이렇게 추철하게 되는데요 

 

여기서 value값 1111 이면 그 해당 class가 cate인 서제주만 이렇게 추출 하고 싶네요 ㅠㅠ

 

해보았지만 도저히 안되서 도움을 요청합니다.ㅠ.ㅠ

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

답변 1개

채택된 답변
+20 포인트

<span class="cate">의 text를 갖고 오되 형제 엘리먼트 중에서 <input type="hidden" value="1111">인 것을 갖고 오고 싶다 그런 말씀이신가요?

정확한 질문 파악이 안 되네요.

</p><p>$(function() {
    $("input[name='no[]']").each(function() {
        if($(this).val() == "1111") {
            alert($(this).siblings("span.cate").text());
        }
    });
});</p><p>
 

로그인 후 평가할 수 있습니다

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

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

로그인