I am trying to make click function fire when iframe is being clicked but It doesn't fire. Is it possible to do it ?
$("#iframe").click(function() {
alert("works");
});
<iframe id="iframe" src="http://site.com" scrolling="no"></iframe>
Another solution is to overlay a transparent div and add a click event to that div. Working sample: http://jsfiddle.net/w1ll3m/AxJHH/
<div class="container">
<iframe src="#url"></iframe>
<div class="overlay"></div>
</div>
css to position the div.overlay over the iframe:
.container{position:relative;float:left;}
.overlay{top:0;left:0;width:100%;height:100%;position:absolute;}
Add the event:
$('.overlay').click(function(){alert('hello');});
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