I want to trigger a function when I control+click on a html>table>tr and also trigger another function when I don't use a control key.
Explanation:
Here I have a html table . I have binded on click function to the table>tr and a fancybox is show on click of this tr.
But now I want to click the same tr within a specific td but the first function is getting invoked even if I specify the id of specified table>tr>td.
I have applied the table>tr a class and href for the fancybox to appear and when I close the fancybox the class and href gets removed according to my wish.
But now When I wanted to use the same tr and click on the td of that tr and invoke another fancybox , the class and href is being applied to the td but the fancybox doesn't appear belonging to the td but appears belonging to the tr.
$('#tbl').on('click','tbody tr',function(){
//fancybox 1 to be appeared
});
$('#tbl').on('click','tbody tr td#comm',function(){
//fancy box 2 to be appeared..
});
If required ctrl or alt or shift keys can be applied
e.ctrlKey
is true
when Ctrl is pressed (where e
is the event object from the first parameter of the event handler):
$('tbl').on('click', 'tbody tr', function(e) {
if (e.ctrlKey) {
//fancybox 1 to be appeared
}
});
Also, you have shitKey
and altKey
that are true
when they are pressed.
您还可以在此处使用preventDefault()文档。希望有帮助。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.