I have been making a simple hamburger menu with jQuery and it refuses to detect a click on my image (id hamburgericon). If I paste the code, the console.log does not even print out “you clicked” when I click. If I select any other id or class selector, it also fails. However, if i replace "#hamburgericon" with document, the code runs perfectly. What am I doing wrong?
Could you post the HTML code, too?
From what I can guess, it might be that there is a tippo or some other problem which prevents $("#hamburgericon") to find the element.
I wonder if the <div id="hamburgericon"></div> actually takes up any space you can click into. To test you could write `
Text takes up space
You could have run in the age-old javascript problem of your code not being ready yet. Did you include the code directly before </body> or inside a $(function(){… ?
For anything beyond this, you probably need to either link to the page you create or replicate the problem in a jsfiddle