Using an image button to trigger a function with the .click() jQuery event handler.
Upon clicking the button, it displays a log message but does not show the alert message. The alert message only appears when clicking on the edge of the button.
Any help would be greatly appreciated, and I am curious why "btn" needs to be included.
$(".button").click(function(event) {
console.log('call')
if (event.target.id === "btnMakeCall") {
var destination = "james";
alert("destiination");
}
});
.button {
background-color: #4CAF50;
border: none;
background: transparent;
text-align: center;
text-decoration: none;
font-size: 16px;
cursor: pointer;
outline: none;
}
<link rel="style
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>
<button id="btnMakeCall" class="button">
<img src ="(http://th07.deviantart.net/fs70/150/i/2013/012/c/6/rock_01_png___by_alzstock-d5r84up.png">
</button>