Here is my button:
<button class="btn-close">Close alert</button>
... with the following CSS:
.btn-close{
position: relative;
height: 30px;
border: none;
background-color: #332b2a;
color: #fff;
outline: none;
cursor: pointer;
}
.btn-close:after {
content: " ";
display: block;
position: absolute;
width: 30px;
height: 30px;
right: -32px;
top: 0;
background-color: #332b2a;
}
... and the following (example) jquery:
$(document).ready(function(){
$(document).on('click', '.btn-close', function(){
alert("It works!");
});
});
However, when I try to click on the after element, it doesn't trigger the click event. Does anyone know if there is any solution? I don't really want to use an empty span inside the button.
It works in Chrome, Opera and Safari. My Firefox version is 27.0.1
I made a jsFiddle example if you want to try yourself: http://jsfiddle.net/esRBa/1/
Thanks for your help!