1 | <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><?phprequire( '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的值删除本行 但好像不行,请教高手
回复讨论(解决方案)
将前端的html输出来才方便别人判断...
将前端的html输出来才方便别人判断...
专题名称 专题类型 发表时间 发表ip 操作
权威的气氛 威联通 2013-12-04 22:40:35 127.0.0.1 查看 修改 删除
额外范围为 网件 2013-12-04 22:41:43 127.0.0.1 查看 修改 删除
的分别是地方 网件 2013-12-04 22:44:33 127.0.0.1 查看 修改 删除
785875857875 网件 2013-12-04 22:56:15 127.0.0.1 查看 修改 删除
fdbsdfbs 网件 2013-12-04 22:59:51 127.0.0.1 查看 修改 删除
你把 连接 包在 button 标记中,连接能生效吗?
简单的改了下,你看看效果和做法
1 | <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><?phpprint_r( $_GET );
|
로그인 후 복사
你把 连接 包在 button 标记中,连接能生效吗? 可以 后台实现从数据库删除了,我想在前端页面不刷新的情况下用js将选中的这一行tr在table中删除
看 #4 的删除按钮
看 #4 的删除按钮
1 | <meta http-equiv= "Content-Type" content= "text/html; charset=UTF-8" ><script charset= "utf-8" src= "js/jquery.js" ></script><?phprequire( "inc/pdo.php" ); $selectSpecialContent = $dbc ->prepare( "select * from naszt" ); $selectSpecialContent ->execute();?><script>$(document).ready( function () {$( '.del' ).bind( "click" .q); function q(){ $( '#' +$(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><?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>查看</button><button>修改</button><button class = 'del' id= "<?php echo $row['id']?>" >删除</button></td></tr><?php }; ?></table>
|
로그인 후 복사
为什么点了没反应呢...
看 #4 的删除按钮 前台输出为:
1 | <meta http-equiv= "Content-Type" content= "text/html; charset=UTF-8" ><script charset= "utf-8" src= "js/jquery.js" ></script>?<script>$(document).ready( function () {$( '.del' ).bind( "click" .abc);alert( "1" ); function abc(){ alert( "1" ); $( '#' +$(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= "2" ><td>27878</td><td>威联通</td><td>2013-12-03 23:26:45</td><td>127.0.0.1</td><td><button>查看</button><button>修改</button><button class = 'del' id= "2" >删除</button></td></tr><tr id= "6" ><td></td><td>威联通</td><td>2013-12-04 17:39:07</td><td>127.0.0.1</td><td><button>查看</button><button>修改</button><button class = 'del' id= "6" >删除</button></td></tr><tr id= "7" ><td>权威的气氛</td><td>威联通</td><td>2013-12-04 22:40:35</td><td>127.0.0.1</td><td><button>查看</button><button>修改</button><button class = 'del' id= "7" >删除</button></td></tr><tr id= "8" ><td>额外范围为</td><td>网件</td><td>2013-12-04 22:41:43</td><td>127.0.0.1</td><td><button>查看</button><button>修改</button><button class = 'del' id= "8" >删除</button></td></tr><tr id= "9" ><td>的分别是地方</td><td>网件</td><td>2013-12-04 22:44:33</td><td>127.0.0.1</td><td><button>查看</button><button>修改</button><button class = 'del' id= "9" >删除</button></td></tr><tr id= "10" ><td>785875857875</td><td>网件</td><td>2013-12-04 22:56:15</td><td>127.0.0.1</td><td><button>查看</button><button>修改</button><button class = 'del' id= "10" >删除</button></td></tr><tr id= "11" ><td>fdbsdfbs</td><td>网件</td><td>2013-12-04 22:59:51</td><td>127.0.0.1</td><td><button>查看</button><button>修改</button><button class = 'del' id= "11" >删除</button></td></tr></table>
|
로그인 후 복사
看 #4 的删除按钮 好了 谢谢您,着急写错了一个逗号
本帖最后由 xuzuning 于 2013-12-06 16:44:47 编辑
你也太粗心了吧?
$('.del').bind("click".q);
这样
$('.del').bind("click",q);