[html5] Is it safe to remove an element from within the element?
bhawkeslewis at googlemail.com
Thu Dec 22 06:32:12 PST 2011
On Thu, Dec 22, 2011 at 9:59 AM, Markus Ernst <derernst at gmx.ch> wrote:
> I have a message for non-JS UAs:
> <div id="jsMsg">
> the basic functionalities will work like this, some functions, such
> as "cancel"-buttons, might not work as expected.</p>
> var jsMsg = document.getElementById("jsMsg");
> This looks like a clean solution to me, as it is removing from the DOM both
> the element and the script to remove it. I found no problems with this code
> in Firefox 5.0 and Internet Explorer 9.
> Anyway, as the removing mechanism is triggered in the code before the
> element is actually closed, I ask myself whether this works by design, or
> just accidentally.
I think you'll find the <div> and <script> elements are already parsed
into the DOM before the script is executed.
More information about the Help