I want to count klicks on links with jQuery. It works fine if the links are clicked with left mouse button. But it should also work if the right button is used. Here is the code:
<a href="http://example.com" class="itemLink" data-count-url="/239/klicks">
$(".itemLink").on("click", function(event) {
$.ajax({
type: 'POST',
url: $(event.target).attr("data-count-url")
})
});
As far as I know click
should work with the left and right button. What is wrong with my code?