日期:2014-05-16  浏览次数:20389 次

请问jquery如何删除当前列?
<script type="text/javascript"src="js/jquery.js"></script>
<link href="css/tablecloth.css" rel="stylesheet" type="text/css" media="screen" /> 
<script type="text/javascript" src="js/tablecloth.js"></script>
<?php
require('inc/page.class.php');
require("inc/pdo.php");
$selectSpecialContent=$dbc->prepare("select * from naszt");
$selectSpecialContent->execute();
?>
<table align="center" cellspacing="0" cellpadding="0">
<tr>
<th>专题名称</th>
<th>专题类型</th>
<th>发表时间</th>
<th>发表ip</th>
<th>操作</th>
</tr>
<?php while($row=$selectSpecialContent->fetch()){ ?>
<tr id="<?php echo $row['id']?>">
<td><?php echo $row['ztname']?></td>
<td><?php echo $row['zttype']?></td>
<td><?php echo $row['zttime']?></td>
<td><?php echo $row['publiship']?></td>
<td><button><a href="ztselect.php?id=<?php echo $row['id']?>">查看</a></button><button><a href="upzt.php?act=up&id=<?php echo $row['id']?>">修改</a></button><button id="del"><a href="selectzt.php?act=del&id=<?php echo $row['id']?>">删除</a></button></td>
</tr>
<?php }; ?>
</table>
<script>
$(document).ready(function(){
$("#del").click(function(){
var q=$("tr").attr("id");
alert(q);
});
});
</script>

本来是想在tr 加个id  获取到这个id的值删除本行  但好像不行,请教高手

------解决方案--------------------
简单的改了下,你看看效果和做法
<script>
$(function() {
  $('.del').click(function() {
    $('#'+$(this).attr('id')).remove();
  });
});
</script>
<table align="center" cellspacing="0" cellpadding="0">
<tr>
<th>专题名称</th>
<th>专题类型</th>
<th>发表时间</th>
<th>发表ip</th>
<th>操作</th>
</tr>
<tr id="1">
<td>$row['ztname']</td>
<td>$row['zttype']</td>
<td>$row['zttime']</td>
<td>$row['publiship']</td>
<td><a href="?id=1">查看</a><button><a href="?act=up&id=1">修改</a></button><button class='del' id=1>删除</button></td>
</tr>
</table>
<?php
print_r($_GET);