嗨我有一张车辆列表
<table> <tr class="${(i % 2) == 0 ? 'odd' : 'even'}" id ="rows"> <td> <div class="check_Box_div"> <div class="check_Box_list"> <g:checkBox id = "isActive_${i}" class="isActive" name="isActive" value="${vehicleInstance?.isActive}" /> <input type="hidden" value="${vehicleInstance?.id}" class="vehicleId" name="vehicleId" id="isActive_${i}_" /> </div> <div class="display_image" id ="display_image_${i}"></div> </div> </td> </tr>
table有很多行
我想得到div的id,其中类名为“display_image”,我试图让它变成每一行
$(".isActive").click(function() { var checkBox_id = $(this).attr("id"); var checkBox = $('#'+checkBox_id); var div_id =$('#'+checkBox_id).closest("div").find(".display_image").attr("id"); // always returns div_id =display_image_0(div id of first row)
这适用于第一行但第二行也只返回第一行div的id
我应该做什么改变,以便我将获得每一行div的id