Javascript examples for DOM:Element innerHTML
Specify an element's own inner HTML
<html> <head></head> <body> <!--Click the button to get id of the parent element --> <button onclick="myFunction()">Try it</button> <div id="parentDiv"> <p id="demo"></p> </div> <script> function myFunction() {/*www.j a v a2 s.c om*/ var x = document.getElementById("demo").parentElement.id; document.getElementById("demo").innerHTML = x; } </script> </body> </html>