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