Edit This Code:
See Result »
<!DOCTYPE html> <html> <body> <p>This is a p element.</p> <p>This is also a p element.</p> <p>Click the button to add a background color to the first p element in the document.</p> <button onclick="myFunction()">Try it</button> <script> function myFunction() { document.querySelector("p").style.backgroundColor = "red"; } </script> </body> </html>
Result: