title: How to make getElementsByClassName do changes to all elements?
body: <p>I am new to javascript, I want to apply changes to all the elements with the same class name but I can only get my script to make the changes to the first element.</p>
  
  <p>This is my script. Thanks in advance.</p>
  
  <pre><code>function ReadMore(){  
  var txt = document.getElementsByClassName('pa')[0].innerHTML;
  
  
  var btn=document.createElement("BUTTON");
  var t=document.createTextNode("...");
  btn.appendChild(t);
  btn.onclick = function(){
  document.getElementsByClassName("pa")[0].innerHTML= txt;
   };
  
  if (txt.length &gt; 350){
  var split = txt.slice(0, 50); 
  document.getElementsByClassName("pa")[0].innerHTML= split;
  document.getElementsByClassName("pa")[0].appendChild(btn);
  }}
  </code></pre>