How can I call a function when clicking an image with jQuery?
This is the HTML code I am working with:
<div id="fixed-navbar">
<div class="nav-left">
<img id="back" src="back.png">
</div>
... (some other code)
</div>
I am trying to write a script to call a function when the above image is clicked:
$("#back").on('click', '.nav-left', function(e) {
e.preventDefault();
window.history.back();
});
Why isn't this script working as expected?
PS: These div's are added dynamically