title: Cannot read property 'replace' of undefined - replacing text in JS generated HTML
body: <p>I have an unordered list (<code>ul</code>) that is generated by external javascript. In each list item there is a repeated line that I'd like to delete. Because I cannot modify the external javascript, I am attempting to use the replace method. The list is identified by a class given to each <code>li</code> element; <code>rss-item</code>.</p>
  
  <p>The following is my code:</p>
  
  <pre><code>   &lt;script&gt;
          function myFunction() {
              var str = document.getElementsByClassName('rss-item').innerHTML; 
              var res = str.replace('Text to replace', '');
              document.getElementsByClassName('rss-item').innerHTML = res; 
          }
      &lt;/script&gt;
  
      &lt;button onclick="myFunction()"&gt;Replace&lt;/button&gt;
  </code></pre>
  
  <p>The error is occuring on the following line:</p>
  
  <pre><code>var res = str.replace('Text to replace', '');
  </code></pre>
  
  <p>The error states:</p>
  
  <pre><code>Uncaught TypeError: Cannot read property 'replace' of undefined
  </code></pre>
  
  <p>From what I understand, this probably means that the javascript is either not finding the element with class name 'rss-item', or not finding the text I am trying to replace. I am absolutely certain this is the correct class name, and that the text I am trying to replace is indeed there. Is this problem occuring because the markup is being generated by javascript? I've come to a dead end. </p>