I have a link like this:
<a id="create_quiz" href="#">Create Quiz</a>
In the HEAD of the HTML page, I have put this:
<script src="https://api.gruntled.com/jquery.js">
$(document).ready(function(){
$( "#create_quiz" ).click(function(e) {
alert("hi");
e.preventDefault();
console.log("hi")
$(".editing form").css("display", "none");
return false;
} );
});
</script>
But when I load the page in Safari and I click on the link, all that happens is the browser goes to the URL which is #
.
I cannot get anything to trigger. The alert never appears.
I did run a search on the page to be sure there was no duplicate use of the ID. But “create_quiz” only appears twice, once in the ID and once in the jQuery code.
I’ve also (repeatedly) checked the URL from which I’m importing the jQuery.
What do I need to do to make something happens when people click that link?
I was expecting to at least see the alert() that I called.
Lawrence Krubner is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.