jquery와 가장 가까운 값을 선택하려고하지만 초보자이고 시도가 성공적이지 않습니다.가장 가까운 선택기 jQuery
누구든지 내가 뭘 잘못하고 있다고 말할 수 있습니까? 어떤 도움을 주셔서 감사합니다!
<div class="two columns">
<form class="float-right">
<input type="hidden" id="show_id" value="329">
<input type="hidden" id="user_id" value="172">
<div id="follow-button" class="button small follow-call follow-show float-right">Follow</div>
</form>
</div>
<div class="two columns">
<form class="float-right">
<input type="hidden" id="show_id" value="389">
<input type="hidden" id="user_id" value="172">
<div id="follow-button" class="button small follow-call follow-show float-right">Follow</div>
</form>
</div>
jQuery를
$('.follow-show').bind('click', function() {
var button = $(this);
var show_id = button.closest("#show_id").val();
var user_id = button.closest("#user_id").val();
});
(a) '을 찾는다 .closest' * * 조상 아닌 형제 (에서 [문서] 참조 (http://api.jquery.com/closest/)). (b) ID는 ** 고유해야 **합니다. –