Cristiano Soleti
Cristiano Soleti

Reputation: 858

Buttons not working at all (Javascript)

I'm getting mad about this.Long story short :
This is the show-cart.php where cart is shown.

enter image description here

When i click Remove button , the event I call works 1 over 10 times about.Below it's the simple code.What's wrong? Why it's not working properly?

<button type="button" class="btn btn-danger">
                            <span onclick="alert('smth')"; class="glyphicon glyphicon-remove""></span> Remove
                        </button>

This is my console enter image description here

Upvotes: 2

Views: 308

Answers (1)

mrogers
mrogers

Reputation: 1217

Try putting the onclick function on the button element instead of span. The following snippet shows this along with some other cleanup in your code.

<button type="button" class="btn btn-danger" onclick="alert('smth')">
  <span class="glyphicon glyphicon-remove"></span> Remove
</button>

Upvotes: 2

Related Questions