//隐藏所有数据
$.each($("tbody#data_tr tr"), function(){
this.style.display = 'none';
});
//展示数据
var trs = $("tbody#data_tr tr[class='"+a+aa+"']");
for(i = 0; i < trs.length; i++){
trs[i].style.display = "block";
}
改变后
//隐藏所有数据
$.each($("tbody#data_tr tr"), function(){
this.style.display = 'none';
});
//展示数据
var trs = $("tbody#data_tr tr[class='"+a+aa+"']");
for(i = 0; i < trs.length; i++){
trs[i].style.display = "";
}
以上可见,block对于显示table的tr并无作用;‘’空可以实现展示效果,即去除none即可
完整代码
<tbody id="data_tr">
<!--历程标签-->
{if $type == 'stage'}
{loop $aInfo $key $val}
{loop $val $k $v}
{if isset($stage_categorys[$k])}
<tr {if $key>0 }style='display:none;'{/if} class="{$type}{$key}">
<td class="text-center" style="width:150px;">{$stage_categorys[$k]}</td>
<td class="text-center" style="width:150px;"></td>
<td class="text-center" style="width:50px;">{$v['int_page_read_user']}</td>
<td class="text-center" style="width:50px;">{$v['int_page_read_count']}</td>
<td class="text-center" style="width:50px;">{$v['ori_page_read_user']}</td>
<td class="text-center" style="width:50px;">{$v['ori_page_read_count']}</td>
<td class="text-center" style="width:50px;">{$v['share_user']}</td>
<td class="text-center" style="width:50px;">{$v['share_count']}</td>
<td class="text-center" style="width:50px;">{$v['add_to_fav_user']}</td>
<td class="text-center" style="width:50px;">{$v['add_to_fav_count']}</td>
</tr>
{/if}
{/loop}
{/loop}
{/if}
<!-- page start-->
<div class="text-right we7-margin-right">
<div>
<label class="font-lg">页码:</label>
<ul class="pagination pagination-centered">
<?php for( $i=1; $i<=count($aInfo);$i++){?>
<li {if $i==1}class="active"{/if}><a href="javascript:;">{$i}</a></li>
<?php }?>
</ul>
</div>
</div>
<script>
$('ul li').click(function(){
var aa=$(this).index();
//查找active在第几个
if(!$(this).hasClass('active')){
//其他去除class
$("ul").find("li[class='active']").removeClass("active");
//添加class
$(this).addClass('active');
var a = $('#type_tag').val();
//隐藏所有数据
$.each($("tbody#data_tr tr"), function(){
this.style.display = 'none';
});
//展示数据
var trs = $("tbody#data_tr tr[class='"+a+aa+"']");
for(i = 0; i < trs.length; i++){
trs[i].style.display = "";
}
}
});
</script>