So, I have some span
and button
right behind him. And all I want to do is hide the element span
and fire the button
-click event when the pointer is in the place of the button
But I cannot do this because the click event goes directly to the span
-event handler . I tried to do this with pointer-events: none
, but in this case, I cannot connect mouseover
-events.
Also tried to set CSS display: none
, but in this case the event handler will not be attached
Is there any way to do this?
$('#myspan').on('mouseenter', function (event) {
$(this).animate({ 'opacity': 0 });
});
$('#myspan').on('mouseleave', function (event) {
$(this).animate({ 'opacity': 0.5 });
});
$('#clicker').on('click', function(event) {
alert('result');
})
#myspan {
position: fixed;
font-size: 22px;
z-index:500;
position: fixed;
left: 50%;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<span id='myspan'>{{property}}</span>
<button id='clicker' style='width: 250px; height: 20px; left: 40%; z-index: -1; position: absolute'>
Clicker
</button>
Run codeHide result
user8393506
source
share