为什么此事件似乎仅在某些点击时触发,而在其他点击时则不触发?
我设置了一个点击事件,每当我点击某处时隐藏我的上下文菜单;但我最近更改了它,以便当我单击带有复选框的上下文菜单时它不会隐藏它。 这是它的代码:
document.observe( 'mouseup', function( event ){
var $j = jQuery.noConflict();
if(men_con_afisat == 'da' && anulare_ascundere_men_con == ''){
men_con_afisat = 'nu';
if($j(event.target).attr('class').indexOf('no_hide')<0)
{
alert($j(event.target).attr('class'));
ascundere_men_con();
}
}
else if(sectiune_pagina == 'proiecte'){
perioada_dezactivare_tragere();
perioada_dezactivare_mutare();
}
else{
}
coordonate_cursor_x = event.clientX;
coordonate_cursor_y = event.clientY;
});
理论上,只要我单击的元素的类属性中没有“no_hide”,它就应该打印我正在单击的元素的类属性。然而,大多数时候这种情况不会发生。它仅在我显示和隐藏我更改其功能的上下文菜单后才会发生。
知道我可能做错了什么吗?
ascundere_men_con() 是隐藏上下文菜单的函数。
I set up a click event to hide my contextual menus whenever i click somewhere; but I recently changed it so that it doesn't hide it in when I click a contextual menu with checkboxes in it.
here's the code for it:
document.observe( 'mouseup', function( event ){
var $j = jQuery.noConflict();
if(men_con_afisat == 'da' && anulare_ascundere_men_con == ''){
men_con_afisat = 'nu';
if($j(event.target).attr('class').indexOf('no_hide')<0)
{
alert($j(event.target).attr('class'));
ascundere_men_con();
}
}
else if(sectiune_pagina == 'proiecte'){
perioada_dezactivare_tragere();
perioada_dezactivare_mutare();
}
else{
}
coordonate_cursor_x = event.clientX;
coordonate_cursor_y = event.clientY;
});
In theory it should print the class attribute of the element i'm clicking whenever the thing I click on does not have "no_hide" in its class attribute. However that doesn't happen most of the time. It only does happen after i show and hide the contextual menu I changed the function for.
Any idea about what I might be doing wrong it it?
ascundere_men_con() is the function that hides the contextual menus.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
仅当 men_con_afisat == 'da' && 时才会执行此操作。 anulare_ascundere_men_con == '',但是您发布的代码没有显示这些(可能是全局)变量的设置位置。
It will only do that if
men_con_afisat == 'da' && anulare_ascundere_men_con == ''
, but the code you posted do not show where these (presumably global) variables are set.