<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 标记中,连接能生效吗?
简单的改了下,你看看效果和做法
<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 的删除按钮
<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 的删除按钮 前台输出为:
<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 的删除按钮 好了 谢谢您,着急写错了一个逗号
你也太粗心了吧?
$('.del').bind("click".q);
这样
$('.del').bind("click",q);

TheSecretTokeEpingAphp-PowerEdwebSiterUnningSmoothlyShyunderHeavyLoadInVolvOLVOLVOLDEVERSALKEYSTRATICES:1)emplactopCodeCachingWithOpcachingWithOpCacheToreCescriptexecution Time,2)使用atabasequercachingCachingCachingWithRedataBasEndataBaseLeSendataBaseLoad,3)

你應該關心DependencyInjection(DI),因為它能讓你的代碼更清晰、更易維護。 1)DI通過解耦類,使其更模塊化,2)提高了測試的便捷性和代碼的靈活性,3)使用DI容器可以管理複雜的依賴關係,但要注意性能影響和循環依賴問題,4)最佳實踐是依賴於抽象接口,實現鬆散耦合。

是的,優化papplicationispossibleandessential.1)empartcachingingcachingusedapcutorediucedsatabaseload.2)優化的atabaseswithexing,高效Quereteries,and ConconnectionPooling.3)EnhanceCodeWithBuilt-unctions,避免使用,避免使用ingglobalalairaiables,並避免使用

theKeyStrategiestosigantificallyBoostPhpaPplicationPerformenCeare:1)UseOpCodeCachingLikeLikeLikeLikeLikeCacheToreDuceExecutiontime,2)優化AtabaseInteractionswithPreparedStateTementStatementStatementAndProperIndexing,3)配置

aphpdepentioncontiveContainerIsatoolThatManagesClassDeptions,增強codemodocultion,可驗證性和Maintainability.itactsasaceCentralHubForeatingingIndections,因此reducingTightCightTightCoupOulplingIndeSingantInting。

選擇DependencyInjection(DI)用於大型應用,ServiceLocator適合小型項目或原型。 1)DI通過構造函數注入依賴,提高代碼的測試性和模塊化。 2)ServiceLocator通過中心註冊獲取服務,方便但可能導致代碼耦合度增加。

phpapplicationscanbeoptimizedForsPeedAndeffificeby:1)啟用cacheInphp.ini,2)使用preparedStatatementSwithPdoforDatabasequesies,3)3)替換loopswitharray_filtaray_filteraray_maparray_mapfordataprocrocessing,4)conformentnginxasaseproxy,5)

phpemailvalidation invoLvesthreesteps:1)格式化進行regulareXpressecthemailFormat; 2)dnsvalidationtoshethedomainhasavalidmxrecord; 3)


熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

Video Face Swap
使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

SublimeText3 Linux新版
SublimeText3 Linux最新版

MantisBT
Mantis是一個易於部署的基於Web的缺陷追蹤工具,用於幫助產品缺陷追蹤。它需要PHP、MySQL和一個Web伺服器。請查看我們的演示和託管服務。

禪工作室 13.0.1
強大的PHP整合開發環境

SAP NetWeaver Server Adapter for Eclipse
將Eclipse與SAP NetWeaver應用伺服器整合。

VSCode Windows 64位元 下載
微軟推出的免費、功能強大的一款IDE編輯器