Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/398.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 右键单击“自定义”菜单工作不正常_Javascript_Jquery_Checkbox_Tablerow_Right Click - Fatal编程技术网

Javascript 右键单击“自定义”菜单工作不正常

Javascript 右键单击“自定义”菜单工作不正常,javascript,jquery,checkbox,tablerow,right-click,Javascript,Jquery,Checkbox,Tablerow,Right Click,右键单击菜单可正确使用其功能。 但问题是它有时工作不正常。 在我的视图中,如果右键单击表格行,则正确选中了复选框,但在我取消选中并再次尝试右键单击复选框后,该复选框不起作用 $('.check').bind("contextmenu", function (event) { event.preventDefault(); $(".custom-menu").finish().toggle(100).css({ top: event.pageY + "px",

右键单击菜单可正确使用其功能。 但问题是它有时工作不正常。 在我的视图中,如果右键单击表格行,则正确选中了复选框,但在我取消选中并再次尝试右键单击复选框后,该复选框不起作用

$('.check').bind("contextmenu", function (event) {
    event.preventDefault();

    $(".custom-menu").finish().toggle(100).css({
        top: event.pageY + "px",
        left: event.pageX + "px"
    });
});


$(document).bind("mousedown", function (e) {
    if (!$(e.target).parents(".custom-menu").length > 0) {
        $(".custom-menu").hide(100);
    }
});


$('tr.check').contextmenu(function (e) {
    $cb = $(this).find('input[type="checkbox"].selected_check');
    $($cb).attr('checked', 'checked');
    populate_context_menu($cb);

    return false;
});

我用一些代码行修改了代码,这对我很有帮助

$(".custom-menu li").click(function () {

   $(".custom-menu").hide(100);
});

 function isExist(id) {
    for (var i = 0; i < values.length; i++) {
    if (values[i] == id) {
        return true;
    }
 }
  return false;
 }

 $('tr.check').contextmenu(function (e) {

    $cb = $(this).find('input[type="checkbox"].selected_check');
        var id = $($cb).attr('id');
        var result = isExist(id);

        if (!result) {
            $('.selected_check').attr('checked', false);
            $('.check').removeClass('highlight_row');
            $('.check').addClass('td_bgcolor');
        }

        $($cb).attr('checked', 'checked');

        populate_context_menu($cb);

           return false;
        });
$(“.custom menu li”)。单击(函数(){
$(“.custom menu”).hide(100);
});
函数isExist(id){
对于(变量i=0;i
Hi@menaka,请添加JSFIDLE链接或其他内容,以便更容易回答@Rj_01:对不起,我没有使用JSFIDLE或其他。好的,我试试。谢谢。