JavaScript querySelector() method - 'p' element example
by danielkwood
HTML
<html>
<head>
<title>querySelector() method</title>
</head>
<body>
<p>This is some text</p>
<p>This is some more text</p>
</body>
</html>
JavaScript
// get the first <p> element using querySelector("p");
var myPararagraph = document.querySelector("p");
// Change the innerHTML content of the first <p> element
myPararagraph.innerHTML = "This is some new text";