Javascript examples for DOM HTML Element:Paragraph
The Paragraph object represents an HTML <p> element.
You can access a <p> element by using getElementById():
<!DOCTYPE html> <html> <body> <p id="myP">I am a paragraph. </p> <button onclick="myFunction()">get id of paragraph element</button> <p id="demo"></p> <script> function myFunction() {//from w w w .ja v a 2 s .co m var x = document.getElementById("myP").id; document.getElementById("demo").innerHTML = x; } </script> </body> </html>