HTML Editor
<!DOCTYPE html> <html lang="en-US"> <body> <p style="color:red">I'm red</p> <p>Click on the button to get the name of the color of the above paragraph.</p> <button onclick="myFunction()">Click Me</button> <p id="point"></p> <script> var x = document.getElementById("point"); var elem = document.getElementsByTagName("p")[0]; function myFunction(){ x.innerHTML = "Color is " +elem.style.color; } </script> </body> </html>
OUTPUT
×

Save as Private