I am trying to use jQuery to detect when a user clicks inside a div on a page. Should be easy enough, but it's not working.
Here's a summary of my code (in the HTML):
<div class="outerDiv">
<object id="video">
...
</object>
</div>
In the jQuery:
$("body").on("click",function(e){
if(e.target.id=="outerDiv") {
... do something
}
if(e.target.id=="video") {
alert("Inside div");
}
...
});
However, when clicking inside the object with the id of "video", nothing happens. But if I click inside "outerDiv", this is picked up by the code.
Could it be beacse inside the "video" id I have an object (in this case a built in flash video player)?
What am I doing wrong?
Cheers :) .