I am currently unable to get this code to work using jQuery. The same event works when I add it specifically on the "a" link element. I would expect jQuery to register an alert to be shown when the link is clicked but nothing happens when I click on that link. I am running this html in Chrome and DevTools console does not show any errors at all! I am not sure what I could be doing wrong as I am doing it just by the book! Overall I have seen jQuery is not working for anything javascript but I have posted this small piece of code to illustrate. Appreciate any help figuring out what I could be doing wrong!
<html>
<head>
<!-- jQuery version 3.3.1 -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js" />
<script>
$(document).ready(function() {
$("a").click(function() {
//This should show an alert when any link on the page is clicked.
alert("This is a test");
})
});
</script>
</head>
<body>
<a href="#">Click here to see alert</a>
<!-- This does not work! -->
<!-- This works fine!
<a href="#" onclick="javascript:alert('This is a test');">Click here to see alert</a> -->
</body>
</html>