I use third-party player which creates dynamically after page load.
I try to add elements to it with jQuery .prepend() but nothing happens.
Initial player look like:
<div id="player"></div>
After page load Player Script modify the player and it become looks like:
<iframe id="player">
<div id="play_button"></div>
<div id="settings_button"></div>
</iframe>
Then plugin call event "onPlayerReady" and player starts playback. After this I try to add <div id="ad_icon">AD</div>
to div <div id="settings_button"></div>
with such code:
function onPlayerReady(){
console.log($("#settings_button").length); // returns '0'
$("#settings_button").prepend("<div id='ad_icon'>AD</div>");
}
but nothing happens. Seems like div
with id=settings_button
doesn't exist for jQuery. Console.log $("#settings_button").length
returns 0
. I see new elements in the page code but jQuery returns nothing.
Any ideas how can I use .prepend() function with dynamically created elements in iframe (which were created not by me)?