刷新表单时避免单击事件 [英] avoid click event while form refresh

查看:63
本文介绍了刷新表单时避免单击事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个以ma形式出现的面板.在位置1上具有button1的panel1上说x:10,y:10,在位置x:10,y:10上具有按钮2的panel2上.

button1实际执行的操作:-隐藏panel1并在同一位置显示panel2.

但是每当我在完成其过程后两次单击button1时,都会触发button2 click事件,

请帮我尽快

i have two panel in ma form. panel1 with button1 on it at location let say x:10,y:10 and panel2 with button 2 on it at location x:10,y:10.

what actually button1 do:- it hide panel1 and shows panel2 at the same location.

but whenever i click on button1 twice after completion its process it fire button2 click event,

plz help me ASAP

推荐答案

你好Neeraj,

该原因背后的原因称为< b>事件冒泡</b>".在JavaScript中.这意味着浏览器捕获特定点上每个基础元素的事件.为了覆盖此行为,请在您在JS函数中进行编码后添加这些代码行,该代码在button1单击上被调用,但恰好在函数的右括号之前:
Hi Neeraj,

The reason behind this cause is called "<b>Event Bubbling</b>" in JavaScript. It means the Browser catches the event for every underlying element on a particular point. in order to override this behavior, add these code lines after you code in JS function which is being called on button1 click but just before the closing parenthesis of the function:
function stopEvent(evnt) {
    if (evnt.stopPropagation) {
             evnt.stopPropagation();
     }
     else {
        evnt.cancelBubble = true;
     }
   }



上面的代码将防止事件在执行js函数中的代码后冒泡.

希望这会有所帮助!
快乐编码:)

Sunny K



the code above will prevent the event bubbling after the code inside your js function is executed.

Hope this helps!
Happy Coding:)

Sunny K


通过忽略排队的鼠标事件.我得到了答案.

@everybody:谢谢大家的建议.
by ignoring queued mouse events. i got my answer.

@everybody: thank you every one for your suggestions.


重新排列两个面板的位置...
rearrange your both panel positions ...


这篇关于刷新表单时避免单击事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆