Hi, I have a table with a list of cars
<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
has many lines I want to get a div identifier, where the class name is " display_image " for each line, I tried to get it as
$(".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");
This works for the first row, but for the second row it also returns an id div for the first row only, what change should I make to get the id div in each row
maaz
source share