i'm trying to replace a word in a paragraph, i did it using Id selector but i need to replace the word in a p with specific classname.
<html>
<body>
<p id="demo">Visit Microsoft!</p>
<p class="demo">Visit Microsoft!</p>
<script>
window.onload = myFunction2;
function myFunction2() {
    var str = document.getElementById("demo").innerHTML; 
    var res = str.replace("Microsoft", "W3Schools");
    document.getElementById("demo").innerHTML = res;}
</script>
</body>
</html>
