1

How to replace all '$' characters in my page anywhere when page is ON load. $ can come multiple times in, So we need to replace all '$' with the '+'. Here's what I have:

MY HTML:

<div>$a sa d $0.12354



        <select name="" id="">
            <option value="">My service price $1.79 per 1000 </option>
        </select>
    </div>

MY JAVASCRIPT:

function nativeSelector() {
              var elements = document.querySelectorAll("body, body *");
              var results = [];
              var child;
              for(var i = 0; i < elements.length; i++) {
                  child = elements[i].childNodes[0];
                  if(elements[i].hasChildNodes() && child.nodeType == 3) {
                      results.push(child);
                  }
              }
              return results;
          }

          var textnodes = nativeSelector(),
          _nv;
          for (var i = 0, len = textnodes.length; i<len; i++){
              _nv = textnodes[i].nodeValue;
              textnodes[i].nodeValue = _nv.replace(/$/g,'€');
          }
Epyc Dev
  • 282
  • 2
  • 9

0 Answers0