I need to pass somehow the information about pressed Ctrl key on invoking the event by jQuery click function. I want invoke this with Ctrl key pressed.
$(selector).click();
This is simplified example:
https://jsfiddle.net/62mdur6o/
When you click on the first cell of table ("One") you do not get information about present Ctrl key in the event.
Is it possible to invoke click listener differently or to attach somehow this information to the event which will be passed to other listeners?
You can trigger event using:
$('#cell').click(function (event) {
event.stopPropagation();
var e = jQuery.Event( event, {ctrlKey: event.ctrlKey} );
$(this).next().trigger(e);
});
Target each cells
$('.cells').click(function (event) {
if (event.ctrlKey) {
alert('ctrl pressed');
} else {
alert('just clicked');
}
});
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.