title: Find and replace word in javascript
body: <p>I am trying to find and replace word in Javascript, the html structure cannot be change so I have to change using JS only, cant use jQuery, not so good with Javascript though:</p>
  
  <p><strong>HTML structure is following:</strong></p>
  
  <pre><code>&lt;a id="ys-cc-tablink"&gt;
    &lt;em&gt;
       &lt;img src="card.jpg"&gt;
       &lt;span&gt;&amp;nbsp;Credit / Debit Card&lt;/span&gt;
    &lt;/em&gt;
  &lt;/a&gt;
  </code></pre>
  
  <p>I am trying to replace <strong><em>Credit/Debit Cart</em></strong> with Title <strong><em>Payment</em></strong> what I have tried is below and working fine as well:</p>
  
  <pre><code>$("#ys-cc-tablink &gt; em &gt; span").each(function() {
     var text = $(this).text();
     $(this).text(text.replace(' Credit / Debit Card', 'Payment')); 
  });
  </code></pre>
  
  <p>But I need in Javascript instead of jQuery, can somebody please help?</p>
  
  <p>thanks</p>
  
  <p><strong>UPDATE:</strong></p>
  
  <pre><code> var str = document.getElementById("demo").getElementsByTagName("span")[0].innerHTML; 
   var res = str.replace("Credit / Debit Card", "Payment");
   document.getElementById("ys-cc-tablink").getElementsByTagName("span")[0].innerHTML = res;
  </code></pre>