Javascript DOM HTML Attribute get and set
<!DOCTYPE html> <html lang="en"> <head> <title>Chapter 9, Example 1</title> </head> /*from www . ja va 2 s .co m*/ <body> <p id="paragraph1">This is some text.</p> <p id="demo"></p> <script> let pElement = document.getElementById("paragraph1"); pElement.setAttribute("align", "center"); document.getElementById("demo").innerHTML = pElement.getAttribute("align"); pElement.removeAttribute("align"); </script> </body> </html>