标题:
<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="js/timeago.js" ></script>
<script src="js/test_helpers.js" type="text/javascript"></script>
照片.php
$(".cmdclose").click(function(){
var id=this.id;
$.post("cmddel.php" ,{"id":id});
setTimeout(function(){
<?php echo 'var id = '.json_encode($_GET['id']).';'; ?>
$('#cmdz').load('cmdajax.php?id='+id);
},1000);
});
html部分:
<div id="cmdz">
<?php
$uid=$_SESSION['uid'];
$query="SELECT *
FROM `cmds`
WHERE `pid` =${id} ORDER BY `id`";
$result=$db->query($query);
?>
<table id="tblcmd">
<tr>
<?
while($result_set=$db->fetch($result)){
// echo $result_set['cmds'];
$uid=$result_set['uid'];
$query2="SELECT * FROM `user` WHERE `id` ='${uid}'";
$result2=$db->query($query2);
$result_set2=$db->fetch($result2);
echo '<td>'.$result_set2['name'].'</td>';
echo '<td>:'.$result_set['cmds'].'</td>';
echo '<td id="'.$result_set['id'] .'"><img src="images/cmd-close.jpg" class="cmdclose" id="'.$result_set['id'] .'" /> </td>';
?>
</tr>
<?php
}
?>
</table>
</div>
cmdajax.php
<?php
session_start();
require_once("includes/database.php");
if(isset($_GET['id'])){
$id=$_GET['id'];
}
$uid=$_SESSION['uid'];
$query="SELECT * FROM `cmds` WHERE `pid` =${id} ORDER BY `id`";
$result=$db->query($query);
?>
<table id="tblcmd">
<tr>
<?php
while($result_set=$db->fetch($result)){
// echo $result_set['cmds'];
$uid=$result_set['uid'];
$query2="SELECT * FROM `user` WHERE `id` ='${uid}'";
$result2=$db->query($query2);
$result_set2=$db->fetch($result2);
echo '<td>'.$result_set2['name'].'</td>';
echo '<td>:'.$result_set['cmds'].'</td>';
echo '<td id="'.$result_set['id'] .'"><img src="images/cmd-close.jpg" class="cmdclose" id="'.$result_set['id'] .'" /> </td>';
echo '<td><abbr class="timeago" title="2008-07-17T09:24:17Z">July 17, 2008</abbr></td>';
?>
</tr>
<?php
}
?>
</table>
我的问题是,一页刷新或 Ajax 调用后,该功能$(".cmdclose").click(function()
将不起作用。为什么不呢?/// 这个问题解决了
现在我面临这个问题:
jQuery("abbr.timeago").timeago(); 这个选择器不能正常工作是什么原因?谢谢