Posts

Showing posts with the label jquery

Prevent parent anchor tag to redirect when a child is clicked

Listen to click event of a child element within anchor tag. <a href="www.google.com" id="parent">    <img src="image.jpeg"/>     <div id="child">Delete</div> </a> jquery approach $('a#parent').on('click', '#child', function(e){     e.preventDefault();          //you only need this if you have a click event in parent element     //e.stopPropagation();      alert($(this).html()); });