JavaScript, getElementsByClassName method not working
<div class = 'demo'> <p> some text </p> <p> some other text </p> <p> testing 123 </p> </div> <script type="text/javascript"> var divelem = document.getElementsByClassName('demo') var arry = divelem.childNodes for(var v = 0;v < arry.length;v++){ arr[v].innerHTML = 'new text' } </script> But This works when I use Id instead of class in the whole script.