Javascript 需要JQuery停止对单击的每个按钮重复
这些功能的基本原理是有效的,但是对于每一个单击的取消按钮,下一个按钮都会添加该数量的单击。例如,如果用户单击一次“取消”按钮,那么下次单击具有不同id的不同按钮时,firebug将显示包含要加载多次的表单(page2)的页面,而不是一次。这都是动态生成的,因此在父页面上最多可能有10个这样的div。应该做的是:Javascript 需要JQuery停止对单击的每个按钮重复,javascript,jquery,html,css,Javascript,Jquery,Html,Css,这些功能的基本原理是有效的,但是对于每一个单击的取消按钮,下一个按钮都会添加该数量的单击。例如,如果用户单击一次“取消”按钮,那么下次单击具有不同id的不同按钮时,firebug将显示包含要加载多次的表单(page2)的页面,而不是一次。这都是动态生成的,因此在父页面上最多可能有10个这样的div。应该做的是: 用户单击父页面上的只读文本框 onfocus从父页面清空该div并加载子页面 3.子页面中的表单现在位于只读的文本框空间中 用户提交评论或取消评论 任何操作都应将只读文本框放回页面中 (
<head>
<script type="text/javascript">
$(document).ready(function(){
var ajaxInProgress = false;
$(function(){
if (ajaxInProgress) return;
$('.ce').focus(function(){
var cid = this.id;
$('#comfield'+cid).empty();
$('#comfield'+cid).load('content_comment.php?id=<%=intmemberid%>&cid=' + cid);
});
});
</script>
</head>
<body>
<div id="comform"
<div id="comfield2">
<input class="ce" id="2" type="text" value="Write a comment..." readonly="readonly" />
</div>
</div>
<div id="comdata2"></div>
<div id="comform"
<div id="comfield3">
<input class="ce" id="3" type="text" value="Write a comment..." readonly="readonly" />
</div>
</div>
<div id="comdata3"></div>
</body>
$(文档).ready(函数(){
var ajaxInProgress=假;
$(函数(){
如果(ajaxInProgress)返回;
$('.ce').focus(函数(){
var cid=this.id;
$('#comfield'+cid).empty();
$('#comfield'+cid).load('content_comment.php?id=&cid='+cid);
});
});
这可能不是“最好”的方法,但它会起作用
替换所有发生的
$('.ce').focus(function(){
与
在两个脚本中
更好的方法是事件委派,尽管这会对代码进行更多的更改。您忘记关闭Wow的引号。您到底想做什么?您能做一个决定吗?
$('.ce').focus(function(){
$('.ce').unbind("focus").focus(function(){