我的代码
<table id="datatable" class="table table-bordered table-striped">
<thead>
<tr class="md-bg-blue-grey-200">
<th width="11%">Sl. No.</th>
<th>State Name</th>
<th>District Name</th>
</tr>
</thead>
<tbody>
<?php foreach ($district_name as $district_names){?>
<tr>
<td><input type="radio" name="district_id" value="<?php echo $district_names['district_id']?>" style="margin-left: 10px" checked>
</td>
<td><?php echo $district_names['state']?></td>
<td id="district_name"><?php echo $district_names['district']?></td>
</tr><?php }?>
</tbody>
</table>
<div style="margin: 0 auto; width: 100px;">
<a href="javascript:Setvalues()" class="btn btn-primary btn-sm pull-right"
style="cursor:pointer;" onclick="selectDistrict()">Select</a>
</div>
</div>这是我的函数,当我选择这个函数调用的行时。
<script>
function selectDistrict() {
district_id = $('input[name=district_id]:checked').val();
district_name
=$('#datatable').find("#district_name").eq(2).html();
opener.district_select(district_id,district_name);
window.close();
}
</script>我想要得到地区名称列值,但它显示了未定义的,如何从这个表中获得地区名称。
发布于 2017-10-24 10:04:43
试试下面的代码
district_name = $('input[name=district_id]:checked').parent().parent().find("td:eq(1)").text();而不是
district_name = $('#datatable').find("#district_name").eq(2).html(); https://stackoverflow.com/questions/46906588
复制相似问题