I have the following HTML:
And I want to add an event listener for the a
element, the one with class k-link
. I have several other k-link
elements on the page so I will want this specific one.
However, I started by trying to add an event listener to the k-link
class, but without success. When I get this, I will then try to add the event listener only to this specific one.
$(document).ready(function () {
$(".k-link").click(function () {
alert("Handler for .k-link called.");
});
$(".k-link").on("click", function () {
alert("Handler for .k-link called.");
});
});
But none of these work. I searched and found this question but the answers there won't work on my case.