Setting innerHTML of nextSibling - Javascript DOM

Javascript examples for DOM:Element nextSibling

Description

Setting innerHTML of nextSibling

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
function replaceNextChild(element) {
   do {/*from w  w w  .  j a  va  2  s  . co  m*/
       element = element.nextSibling;
   } while (element.nodeType != 1);
   element.innerHTML = "this is a test";
}

      </script> 
   </head> 
   <body> 
      <h3 onclick="replaceNextChild(this);">Some content...</h3>
       (text node) 
      <div>
         Div that I am interested in replacing
      </div>  
   </body>
</html>

Related Tutorials