[html5] Is it safe to remove an element from within the element?

Jukka K. Korpela jukka.k.korpela at kolumbus.fi
Thu Dec 22 07:48:58 PST 2011

2011-12-22 11:59, Markus Ernst wrote:

> I have a message for non-JS UAs:
> <div id="jsMsg">
> <p>Javascript is turned off or not available in your browser. While
> the basic functionalities will work like this, some functions, such
> as "cancel"-buttons, might not work as expected.</p>
> <script type="text/javascript">
> var jsMsg = document.getElementById("jsMsg");
> jsMsg.parentNode.removeChild(jsMsg);
> </script>
> </div>
> 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 don't see why would need to remove the code as well. But more 
importantly, is there a reason not to use the simple <noscript> element?

Yucca, http://www.cs.tut.fi/~jkorpela/

More information about the Help mailing list