I have two images stacked one above the other. img_top has 'pointer-events' set to none, so clicking on it will pass the click to img_bottom. However if I invoke jQuery's trigger('click') on img_top, the click will not pass on to img_bottom.
Can anybody explain why and find a way of passing the click to the bottom image USING jQuery's trigger('click') AND CSS's 'pointer-events'?
Here is the code I am using:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
<style type="text/css">
#img_holder {
position:relative;
width:20px;height: 20px;
}
#img_bottom {
position:absolute;
background: url('http://mydomain.com/images/cross.png');
width: 16px;height: 16px;z-index:1;
}
#img_top {
pointer-events: none;
position:absolute;
background: url('http://mydomain.com/images/tick.png');
width: 16px;height: 16px;z-index:2;
}
</style>
<script type="text/javascript">
$(document).ready(function(){
$(document).click(function (){
alert('clicked');
$("img_top").trigger('click');
});
$("#img_bottom").click(function (){
alert('success');
});
});
</script>
<div id="img_holder">
<div id="img_top"></div>
<div id="img_bottom"></div>
</div>