问题
$('tbl').on('click', 'tbody tr', function(e) {
if (e.ctrlKey) {
//fancybox 1 to be appeared
}
if(e.shiftKey) {
//fancybox 2 to be appeared
}
});
Finding an issue as below:
//comment
having a problem using this, because I even have to render response from the fancybox and display in the td.. when i click it by ctrl+click then I am getting the form load which I seen through debugging tool but sometimes it display the fancybox.
//comment end
I have used the above coding in a table id tbl and tried to select multiple tr using click event and then get a fancybox. So before that I have used the code as
$('#tbl).on('click','tbody tr',function(e){
if ($(this).hasClass('fancybox fancybox.ajax')) {
$(this).removeClass('fancybox fancybox.ajax');
$(this).css("background", "white");
}
else {
$(this).addClass('fancybox fancybox.ajax');
$(this).css("background", "#ffc");
}
});
$('tbl').on('click', 'tbody tr', function(e) {
if (e.ctrlKey) {
if ($(this).hasClass('fancybox fancybox.ajax')) {
$(this).removeClass('fancybox fancybox.ajax');
$(this).css("background", "white");
//fancybox 1 to be appeared
}
else {
$(this).addClass('fancybox fancybox.ajax');
$(this).css("background", "green");
}
}
if(e.shiftKey) {
if ($(this).hasClass('fancybox fancybox.ajax')) {
$(this).removeClass('fancybox fancybox.ajax');
$(this).css("background", "white");
}
else {
$(this).addClass('fancybox fancybox.ajax');
$(this).css("background", "yellow");
// fancybox 2 to be appeared
}
}
});
Later tried to implement above code. Please suggest.
Thanks
来源:https://stackoverflow.com/questions/26464866/issue-with-using-ctrl-and-click-jquery