I have a div that I've inserted a YouTube video into and this plays fine. But I'd like to be able to click somewhere on the video and remove the embed code from the DOM, so the div goes back to whatever it was before the embed code was inserted and the YouTube video and player completely disappear.
I know there's a YouTube JavaScript API, but this seems to just let you send commands, like stop, pause, play, to the player. I want to completely eliminate the player, and remove the iframe from the DOM seems like the best way.
The problem is that anything I click on the YouTube player is intercepted by the player so I never receive the click in my JavaScript or jQuery. Is there any way I can sense a click on the YouTube player in my JavaScript or jQuery?
Thanks