For various reasons I am stuck trying to remove a parent div from a function coming from an iframe. The div that needs to be removed from the dom (not hidden) has a unique id assigned to it.
So say I have this div in parent :
<body>
<div id="foo_123" class="bar">STUFF</div>
In the iframe generated from that page I have this to grab that unique id
var curWin = window.top.document.getElementsByClassName('bar')[0].id;
so in this example curWin = foo_123
Now in the same function that gets that variable I need to be able to remove that div completely from the parent page. I do have prototype to work with and I tried doing
$(curWin).remove();
But that did not work it just gives error that $(curWin) is null. But if I echo curWin it does provide me with that correct id.
Any ideas on how I can do this. I tried using removeChild too but again I am not sure how to do it when it is the child of the <body> in the parent document.
Please refrain from telling me how awesome jQuery is. I know this would be easy beans but I do not have that luxury with this project.
If you have prototype in the top window do:
top.$(curWin).remove();It will look for
"foo_123"in the top window (where it exists) instead of the iframe (where it doesn’t exist)