Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / HTML, CSS, Scripts / JavaScript / May 2006



Tip: Looking for answers? Try searching our database.

removing an HTML element

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
petermichaux@gmail.com - 30 May 2006 21:10 GMT
Hi,

I'm trying to remove an html element in the example below. I don't see
the "bye" message at the end and there are no errors reported in
Firefox or exceptions caught if I wrap the remove child line in a
try-catch. Any ideas what is wrong?

Thanks,
Peter

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>garbage</title>
</head>
<body>

 <div id="my_div">hi<div>

 <script type='text/javascript'>
   var my_div = document.getElementById("my_div");
   my_div.parentNode.removeChild(my_div);
   document.write("bye");
 </script>

</body>
</html>
Csaba  Gabor - 30 May 2006 22:43 GMT
> I'm trying to remove an html element in the example below. I don't see
> the "bye" message at the end and there are no errors reported in
[quoted text clipped - 3 lines]
> Thanks,
> Peter
...
>   <div id="my_div">hi<div>

It works better for me if I close the element thusly:
<div id="my_div">hi</div>

Csaba
petermichaux@gmail.com - 31 May 2006 00:20 GMT
> ...
> >   <div id="my_div">hi<div>
[quoted text clipped - 3 lines]
>
> Csaba

doh! Thanks. I just couldn't see it this time. Next time I'll validate
first.

Peter
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.