How do I listen to onClick events for a Bootstrap modal button using JQuery?
I have this JavaScript, but the event is never firing.
jQuery(function() {
$('#emailButton').click(function() {
console.log("emailButton()...");
The HTML is
<button type="button" class="btn btn-default" title="Email Page to a Friend" data-toggle="modal" data-target="#emailModal" id="#emailButton">
The modal pops up, but the click handler isn't working. Nothing shows up in the console. Here is a jsFiddle: https://jsfiddle.net/y59qys4j/8/
Answers 1
OK I found it. I added a hash in the
id
field. But what's really strange is that I uses Chrome's console to view the object, and it returned a value!However, now I see they return different results.