I am experiencing problem with Firefox 32 when I bind action on click event of span element inside a button element. Other browsers seems to works well.
Here the code illustrating the issue on jsFiddle.
<span onClick="alert('test');">**Working**</span><br> <button>inside a button <span onClick="alert('test');">**Not working**</span></button>
Does anybody know why and if it's a bug or a feature ?
When clicking on the p element, it will return both the p and the div element, since the p element is inside the div element. But when clicking on the span element, it will only return itself, and not the p and the div element (even though its inside these elements).
Blocks and inline elements cannot be placed inside a span (or any inline element), but a button can and is an inline element, so yes, that is the correct approach if you're looking for an inline element containing text and another inline element.
All Elements Can Be ButtonsAny div, header, footer or other containers can be a w3-button!
An element receives a click event when a pointing device button (such as a mouse's primary mouse button) is both pressed and released while the pointer is located inside the element.
You have to add the pointer-events
property to the span element.
button span { pointer-events: none; }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With