JSFiddle - React, Tailwind, and code Playground

by Ramya Ranganathan

HTML

<title>Test Attributes</title>
<p id="magic1" align="left">Hello</p>
<p id="magic2" align="center">Hello, again.</p>

JavaScript

var node = document.getElementById("magic1");
    document.open(node.align);   // Get attribute "align"
    node.align = "center";          // Set attribute "align" to a new value
  
    node = document.getElementById("magic2");
    document.writeln(node.getAttribute("align"));  // Read attribute "align"
    node.setAttribute("align", "right");   // Write attribute
document.close();