HTML Editor
<!DOCTYPE html> <html lang="en-US"> <body> <p>Change my color</p> <p>Click on the button to set 'style' for the above paragraph.</p> <button onclick="myFunction()">Click Me</button> <script> var elem = document.getElementsByTagName("p")[0]; function myFunction(){ elem.setAttribute("style", "color:red;") } </script> </body> </html>
OUTPUT
×

Save as Private