I am making a website using Bootstrap, Node.js, and jQuery for a club. I am trying to write a piece of Javascript code that when an image (or preferably the div it is in) is clicked on, another javascript function I have to change the pdf displaying will run. My problem is nothing works to catch a click on the image.
My code for the image:
<div id="2005d" style="cursor: pointer">
<img id="2005p" style="max-width: 100%" src="/magazines/2005_cover.jpg">
<h5 id="2005t" style="text-align: center; color: black">2005</h5>
</div>
The jQuery I am trying ot use to catch a click on this image:
$("document").ready(function() {
$("#2005d").click(function(){
alert("Clicked");
});
});
What can I do to try to get jQuery to catch the click event on the image?
$(document).on("click", "#2005d", function() { //your stuff here});#2005d), due toevent bubblingany click events inside the child will be caught by the parent.