Consider the following code.
$(function(){
$(".notes").click(function(){
console.log('hi');
})
})
<a data-shipmentid="1" href="#" class="notes btn btn-primary btn-xs">Notes</a>
<a data-shipmentid="1" href="#" class="notes btn btn-primary btn-xs">Notes</a>
<a data-shipmentid="1" href="#" class="notes btn btn-primary btn-xs">Notes</a>
<a data-shipmentid="1" href="#" class="notes btn btn-primary btn-xs">Notes</a>
<a data-shipmentid="1" href="#" class="notes btn btn-primary btn-xs">Notes</a>
The purpose is to log a message when any of the hyperlink is clicked. The issue I am facing is that if I click on a hyperlink, then the console it getting the message "hi" 5 times ( the total number of hyperlinks with the class "notes" )
I understand that something is wrong. How do I check what is wrong here in this case? I see console is not displaying any error messages. Anyone has any idea why the event is firing up multiple times?
console.log($(".notes"))$(".notes").off().click...