用jquery的bind某个事件后,在什么情况下会消失,这个bind事件会失效?比如改变dom结构 用jquery的bind某个事件后,在什么情况下会消失,这个bind事件会失效?比如改变dom结构 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 bind实际上是在这个指定的DOM结点上添加事件监听. 当这个DOM被移除或者它的HTML被完全重构, 监听也会消失. 或者unbind <html><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312"><title>mydiv</title><script type="text/javascript" src="jquery/jquery.js"></script><script language="javascript"> $(document).ready(init); function init(){ $("#Group1").bind('click', doClick); } function doClick(){ alert('ohohoh'); } function change1(){ $("#Group1").insertAfter($("#Group3")); } function change2(){ $("#Group1").replaceWith('<div id="Group1" class="Group">1</div>'); }</script> <style type="text/css" rel="Stylesheet"> .Group{border:solid 1px black;height:20px;width:50px;position:relative;cursor:pointer;} </style></head><body> <div id="Outer"> <div id="Group1" class="Group">1</div> <div id="Group2" class="Group">2</div> <div id="Group3" class="Group">3</div> </div> <button onclick="change1()">改变1位置</button> <button onclick="change2()">改变1结构</button></html>unbind就没写了 jquery js实现一张图片以水平轴翻滚效果 请问不使用form, 如何用HTML,JavaScript做前端,Asp.net作服务器端实现文件上传? js zoom放大缩小问题 帮我检查问题--菜鸟的疑惑 JS如何获取淘宝店铺的退款次数【结贴加分】 小问题,帮解决! 如何控制textarea中输入的文本最大数? 一个关于select里面用了onChange事件的奇怪问题。急切ing.... 请教:关于ShowModalDialog()的问题 如何强制刷新页面 为什么我的div无法居中? 用JavaScript动态地修改一个input值时的onchange问题
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>mydiv</title>
<script type="text/javascript" src="jquery/jquery.js"></script>
<script language="javascript">
$(document).ready(init);
function init(){
$("#Group1").bind('click', doClick);
}
function doClick(){
alert('ohohoh');
}
function change1(){
$("#Group1").insertAfter($("#Group3"));
}
function change2(){
$("#Group1").replaceWith('<div id="Group1" class="Group">1</div>');
}
</script>
<style type="text/css" rel="Stylesheet">
.Group{border:solid 1px black;height:20px;width:50px;position:relative;cursor:pointer;}
</style>
</head>
<body>
<div id="Outer">
<div id="Group1" class="Group">1</div>
<div id="Group2" class="Group">2</div>
<div id="Group3" class="Group">3</div>
</div>
<button onclick="change1()">改变1位置</button>
<button onclick="change2()">改变1结构</button>
</html>
unbind就没写了