I'm trying to use JQuery so that when the user clicks on an HTML link, a function that I write in the JavaScript file is called.
<a href="#" id="advanced_options">Show advanced options</a>
And
$(document).ready(function() {
$("#advanced_options").click(function() {
alert('hello');
});
});
When I click on the link, it doesn't alert, but instead jump to another link. Why is that?
href="#". If you want a button that just does something with JS, and don't want to link to anything, then use an actual button and not a link.$(document).ready(function()it saysUncaught Type Error: Object #<HTMLDocument> has no method 'ready'. Butjquery.min.jsis clearly loaded. What's going on?<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>