【发布时间】:2013-01-10 04:05:05
【问题描述】:
如果选中任何行复选框,我想在表格下方显示删除按钮。否则,该按钮应保持隐藏状态。
表我希望它被实现。 表格截图:
这是后面的html表格代码。
<table id="datatable_example" class="responsive table table-striped table-bordered" style="width:100%;margin-bottom:0; ">
<thead>
<tr>
<th style="width:0px; padding-right:0px;" class="jv no_sort"> <label class="checkbox ">
<input type="checkbox">
</label>
</th>
<th style="width:200px;" class=""> Skill </th>
<th style="width:300px;" class="to_hide_phone no_sort"> Description </th>
<th class=""> Rating </th>
<th style="width:200px;" class="ue no_sort"> Date </th>
<th class="ms no_sort "> Actions </th>
</tr>
</thead>
<tbody>
<?php echo $skills; ?>
</tbody>
</table>
这是技能变量:
$skills="";
while($row=mysql_fetch_array($skills_list))
{
$showskillid=$row['skill_id'];
$showskillname=$row['skill_name'];
$showskilldescription=$row['skill_desc'];
$showskillrating=$row['skill_rating'];
$showskill_lastupdated=$row['last_updated'];
$skills .="<tr>
<td><label class=\"checkbox\">
<input type=\"checkbox\" class=\"chkboxes\" name=\"ids[]\">
</label></td>
<td class=\"to_hide_phone\"> $showskillname </td>
<td class=\"to_hide_phone\">$showskilldescription</td>
<td> $showskillrating </td>
<td> $showskill_lastupdated </td>
<td class=\"ms\"><div class=\"btn-group1\"> <a href=\"skill_edit.php?id=$showskillid\" class=\"btn btn-small\" rel=\"tooltip\" data-placement=\"left\" data-original-title=\" edit \"><i class=\"gicon-edit\"></i></a> <a class=\"btn btn-small\" rel=\"tooltip\" data-placement=\"top\" data-original-title=\"View\"><i class=\"gicon-eye-open\"></i></a> <a class=\"btn btn-small\" rel=\"tooltip\" data-placement=\"bottom\" data-original-title=\"Remove\"><i class=\"gicon-remove \"></i></a> </div></td>
</tr>";
}
我尝试过的 Jquery,但我知道我是 jquery 的新手,所以需要帮助来修复它。
<script type="text/javascript">
$(document).ready(function() {
$('.delbtn').hide();
});
$('.chkboxes').click(function(){
$('.delbtn').toggle();
});
</script>
Jquery 我试过它的工作原理就像我点击一个复选框时按钮会显示,而当我去点击另一个复选框时按钮会消失?
我知道这里不应该使用切换.. 我应该在这里使用什么来解决这个问题,或者如果有更好的选择来解决它,我愿意接受它..
【问题讨论】:
-
你到底想要什么?当您单击多个复选框时,按钮应该消失吗?或者当你点击它应该出现并取消选中它应该消失?
-
@Sahal 我想要当我点击复选框或不同的复选框时,按钮应该出现。如果没有选中任何复选框,那么按钮不应该是可见的......
标签: php jquery html checkbox show-hide