通过ajax从后获取了一tr标签,但是JQUERY没有用了
<scripttype="text/javascript">$(document).ready(function(){$("tr").hover(function(){$...
<script type="text/javascript" >
$(document).ready (
function(){
$("tr").hover(function(){
$(this).addClass("hover");},function(){
$(this).removeClass("hover");})
}
//window.alert($(this).attr("id"));
);
$(function(){
$("input").click(function(){
var data1=$(this).attr("id");
$.post("chuli.php",data1,function(data){
$("tr").remove(".hello");
window.alert(data);
$("#123").append(data);
})
})
});
</script>
<?php
echo ' <table width="90%" id="mytab" border="1" class="t1" >';
$conn=mysql_connect("127.0.0.1","root","");
mysql_query("set names utf8",$conn) or die(mysql_errno());
mysql_select_db("ba",$conn) or die(mysql_errno());
$sql="select * from renwu";
$ab=mysql_query($sql,$conn);
echo "<tbody id='123'>";
while($a=mysql_fetch_assoc($ab)){
if(!$a['jie']==1){
echo " <tr class='hello'> ";
echo "<td>{$a['bianhao']} </td> ";
echo " <td>{$a['mingzhi']}</td>";
echo " <td>{$a['ruqi']}</td> ";
echo " <td>{$a['shoujidan']}</td> ";
echo " <td>{$a['shuanglianjie']}</td>";
echo " <td>{$a['yuancheng']}</td> ";
echo " <td>{$a['zhuanghao']}</td> ";
echo " <td>{$a['ip']}</td>";
echo " <td>{$a['dianshu']}</td> ";
echo " <td>{$a['renwu']}</td>";
echo " <td>{$a['jinge']}</td>";
echo " <td>{$a['fabu']}</td>";
echo " <td>{$a['beijiie']}</td>";
echo " <td><input id={$a['bianhao']} type='button' value='抢任务'></input></input><input type='hidden' value='12'></td>";
echo " </tr>";}
}
echo "</tbody>";
echo " </table>";
?>
上面是1.php页面
下面是chuli.php页面
<?php
$conn=mysql_connect("127.0.0.1","root","");
mysql_query("set names utf8",$conn) or die(mysql_errno());
mysql_select_db("ba",$conn) or die(mysql_errno());
$sql="select * from renwu";
$ab=mysql_query($sql,$conn);
while($a=mysql_fetch_assoc($ab)){
if(!$a['jie']==1){
echo " <tr class='hello'> ";
echo "<td>{$a['bianhao']} </td> ";
echo " <td>{$a['mingzhi']}</td>";
echo " <td>{$a['ruqi']}</td> ";
echo " <td>{$a['shoujidan']}</td> ";
echo " <td>{$a['shuanglianjie']}</td>";
echo " <td>{$a['yuancheng']}</td> ";
echo " <td>{$a['zhuanghao']}</td> ";
echo " <td>{$a['ip']}</td>";
echo " <td>{$a['dianshu']}</td> ";
echo " <td>{$a['renwu']}</td>";
echo " <td>{$a['jinge']}</td>";
echo " <td>{$a['fabu']}</td>";
echo " <td>{$a['beijiie']}</td>";
echo " <td><input id={$a['bianhao']} type='button' value='抢任务'></input></input><input type='hidden' value='12'></td>";
echo " </tr>";}
}
?>
打开1.php页面jquery都是有用的,点击按钮获取了chuli.php页里内容填充到删除的那些内容JQUERY失效了,要怎么解决 展开
$(document).ready (
function(){
$("tr").hover(function(){
$(this).addClass("hover");},function(){
$(this).removeClass("hover");})
}
//window.alert($(this).attr("id"));
);
$(function(){
$("input").click(function(){
var data1=$(this).attr("id");
$.post("chuli.php",data1,function(data){
$("tr").remove(".hello");
window.alert(data);
$("#123").append(data);
})
})
});
</script>
<?php
echo ' <table width="90%" id="mytab" border="1" class="t1" >';
$conn=mysql_connect("127.0.0.1","root","");
mysql_query("set names utf8",$conn) or die(mysql_errno());
mysql_select_db("ba",$conn) or die(mysql_errno());
$sql="select * from renwu";
$ab=mysql_query($sql,$conn);
echo "<tbody id='123'>";
while($a=mysql_fetch_assoc($ab)){
if(!$a['jie']==1){
echo " <tr class='hello'> ";
echo "<td>{$a['bianhao']} </td> ";
echo " <td>{$a['mingzhi']}</td>";
echo " <td>{$a['ruqi']}</td> ";
echo " <td>{$a['shoujidan']}</td> ";
echo " <td>{$a['shuanglianjie']}</td>";
echo " <td>{$a['yuancheng']}</td> ";
echo " <td>{$a['zhuanghao']}</td> ";
echo " <td>{$a['ip']}</td>";
echo " <td>{$a['dianshu']}</td> ";
echo " <td>{$a['renwu']}</td>";
echo " <td>{$a['jinge']}</td>";
echo " <td>{$a['fabu']}</td>";
echo " <td>{$a['beijiie']}</td>";
echo " <td><input id={$a['bianhao']} type='button' value='抢任务'></input></input><input type='hidden' value='12'></td>";
echo " </tr>";}
}
echo "</tbody>";
echo " </table>";
?>
上面是1.php页面
下面是chuli.php页面
<?php
$conn=mysql_connect("127.0.0.1","root","");
mysql_query("set names utf8",$conn) or die(mysql_errno());
mysql_select_db("ba",$conn) or die(mysql_errno());
$sql="select * from renwu";
$ab=mysql_query($sql,$conn);
while($a=mysql_fetch_assoc($ab)){
if(!$a['jie']==1){
echo " <tr class='hello'> ";
echo "<td>{$a['bianhao']} </td> ";
echo " <td>{$a['mingzhi']}</td>";
echo " <td>{$a['ruqi']}</td> ";
echo " <td>{$a['shoujidan']}</td> ";
echo " <td>{$a['shuanglianjie']}</td>";
echo " <td>{$a['yuancheng']}</td> ";
echo " <td>{$a['zhuanghao']}</td> ";
echo " <td>{$a['ip']}</td>";
echo " <td>{$a['dianshu']}</td> ";
echo " <td>{$a['renwu']}</td>";
echo " <td>{$a['jinge']}</td>";
echo " <td>{$a['fabu']}</td>";
echo " <td>{$a['beijiie']}</td>";
echo " <td><input id={$a['bianhao']} type='button' value='抢任务'></input></input><input type='hidden' value='12'></td>";
echo " </tr>";}
}
?>
打开1.php页面jquery都是有用的,点击按钮获取了chuli.php页里内容填充到删除的那些内容JQUERY失效了,要怎么解决 展开
展开全部
你好,你的意思是$("input").click(function(){这个事件不起作用是吧,你可以使用绑定事件处理
$('input').live('click', function() {
//ajax处理
});
live方法给所有匹配的元素附加一个事件处理函数,即使这个元素是以后再添加进来的也有效。
希望可以帮助到你
更多追问追答
追问
$(document).ready (
function(){
$("tr").hover(function(){
$(this).addClass("hover");},function(){
$(this).removeClass("hover");})
}
//window.alert($(this).attr("id"));
);
那这里要怎么改,
追答
用css就可以搞定了
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询