I'm using event.preventDefault()
for all elements on the page with Jquery like this:
$('*').on('click', function(e) {
e.stopPropagation();
e.preventDefault();
});
Now I would like to trigger a click event using the the context menu on right click. So basically I would right click the mouse and a context menu would open and from that menu I would choose to trigger the click. In Jquery this is simple I would do this in my function related to the context menu:
$(this).click();
The this
part would get the selector and the click
part would trigger the click, of course with return true
to lift the preventDefault. The problem is that I can't use Jquery in the latter, I have to use plain Javascript. What is the equivalent of $(this).click();
in plain Javascript? (without attaching click handlers on the elements themselves that is)