jquery - Use JavaScript to Edit iFrame Elements (Same Domain) -


updated (with link example)

link: https://brotherhoodgaming.net/ (click nav menu > settings > profile settings)

i using iframe load page of website onto index page. should same domain. when iframe page loads, loads duplicate copy of main nav menu. remove iframe nav menu , have pure frame filled content.

my iframe created using javascript append, when user clicks button.

$("#menuoverlay").append("<iframe id='iframecontact'' src='contact.php' width='300' height='100%' frameborder='0'></iframe>"); 

after iframe created js below should remove nav menu inside frame, far hasn't worked. (updated js)

$("#iframecontact").contents().find("#nav").remove(); 

any suggestions? i've been searching , above js recommended, cannot locate elements inside frame. because frame created through js append , other functions don't have time run?

enter image description here

enter image description here

try instead. removing class not remove element itself. class on element. assuming selectors correct should work.

it's working on link need make sure iframe loaded before executing code.

var iframe = $("#iframecontact"); iframe.on("load",function ()   {     iframe.contents().find("#nav").remove();   }); 

Comments