."/>
."/>
"/>
خرید بک لینک

Vote count: 0

I intend to create a new Div element via javascript, but i am having problem appending my code to the DOM

               <div id="container">
                   <div id="content">
                   </div
               </div>
            <script>
                var container = document.getElementById('container');
                function divCreate()   {

                     var newDiv = document.createElement('div');

                     var newContent = document.createTextNode('Hello 

                     this is a div is added via javasceipt);   

                     newDiv.appendChild(newContent);

                     var currentDiv = document.getElementById('content');

                     document.body.container.insertBefore(newDiv,   
                     currentDiv
                }

              divCreate();

         </script>

 my actual intention was to insert the new div before the content inside the

container. I do understand the DOM as a tree of objects and hierarchy too.I thought that i could navigate the tree via this hierarchy . that is from document--->body----->container.

It did worked on the container, but not the content div. Could someone please tell what I am missing here?

asked 42 secs ago

برچسب: why is the sky blue,why is the ocean salty,why is the ocean blue,why is the rum gone,why is the boss rated r,why is the gadsden flag racist,why is the earth round,why is the sea salty,why is the purge rated r,why is the sun yellow, نویسنده: استخدام کار تاريخ: سه شنبه 19 مرداد 1395 ساعت: 21:02

صفحه بندی