【发布时间】:2013-09-30 23:47:42
【问题描述】:
我想在点击“肯定”链接时隐藏所有类别不同于“肯定”的 tr,并在点击“否定”链接时隐藏所有类别不同于“否定”的 tr。
这是我的 HTML:
<a href="" id="positive"> Positive rows</a>
<a href="" id="negative"> Negative rows</a>
<?php
$i=1;
while ($u=mysql_fetch_array($result2)){
?>
<tr id="row<?php echo $i;?>" class="<?php echo $u['positive_negative'];?>"> //echo $u['positive_negative'] can result on "Positive" or "Negative" text.
<td><? echo $u['date'];?></td>
<td><? echo $u[''positive_negative'];?></td>
<td><? echo $u['user_id'];?></td>
</tr>
<?php
$i++;
};
?>
我已经尝试过这个脚本,但不起作用:
$(document).ready(function(){
$('#positive').click(function(){
$('.positive').show(200);
$('.negative').hide(200);
});
$('#negative').click(function(){
$('.negative').show(200);
$('.positive').hide(200);
});
});
提前感谢您的帮助!
【问题讨论】:
标签: javascript hide show tr