
html页面:
<div class="mt-20">
<table class="table table-border table-bordered table-bg table-hover table-sort">
<thead>
<tr class="text-c" id="allcheck">
<th class="bs-checkbox " style="width: 36px; " data-field="state" tabindex="0">
<div class="th-inner ">点击单选</div><div class="fht-cell"></div></th>
<!--<th width="60">媒体ID</th>-->
<th width="60">标题</th>
<th width="60">文件</th>
</tr>
</thead>
<tbody>
{volist name="resinfo" id="vo"}
<tr class="text-c">
<td class="bs-checkbox "><div class="radio-box"><input data-index="{$vo.aid}" name="btSelectItem" type="radio" value="{$vo.aid}" onclick="checkedvalue()"></div>
</td>
<!--<td width="60">{$vo.aid}</td>-->
<td width="60">{$vo.title}</td>
{if($vo.typeid==4)}
<td width="90"><img src="{$vo.attachment}" style="width:150px;"></td>
{elseif($vo.typeid==2)/}
<td width="90"><video src="{$vo.attachment}" style="width:150px;" controls="controls"></video></td>
{elseif($vo.typeid==3)/}
<td width="90"><audio src="{$vo.attachment}" style="width:250px;" controls ></audio></td>
{else/}
<td width="90">---</td>
{/if}
</tr>
{/volist}
</tbody>
</table>
</div>
/*--js获取点击表格便选中当前行--*/
$(function() {
$('table').on('click', 'tr', function(e){
// 获取table中所有的行
var trs = $(this).parent('tbody').find('tr');
// 取消所有行的选中
$.each(trs, function(index, item) {
// 如果在此使用的是attr()设置选中状态,取消后将不能设置为选中
$(item).find('td:eq(0) input').prop('checked', false);
});
// 选中当前点击的行
$(this).find('td:eq(0) input').prop('checked',true)
var selectid = $("input[type='radio']:checked").val(); //选中行id值
var typeid="{$assignData['typeid']}";
if(typeid==1){
layer.msg('成功选择!',{icon:1,time:1000});
setTimeout(function() {
act_reload(selectid,typeid);
}, 1000);
}else if(typeid==2){
layer.msg('成功选择视频ID='+selectid,{icon:1,time:1000});
setTimeout(function() {
act_reload(selectid,typeid);
}, 1000);
}else if(typeid==3){
layer.msg('成功选择音频ID='+selectid,{icon:1,time:1000});
setTimeout(function() {
act_reload(selectid,typeid);
}, 1000);
}else{
layer.msg('成功选择图片ID='+selectid,{icon:1,time:1000});
setTimeout(function() {
act_reload(selectid,typeid);
}, 1000);
}
})
});