javascript - excluding some tags from jquery -


i searched web not find proper answer question. using below code change english numbers persian. code changed whole body numbers , need apikey td excluded, idea?

$(window).load(function() {    $("[lang='fa']").find("*").andself().contents().each(function() {      if (this.nodetype === 3) {        this.nodevalue = this.nodevalue.replace(/\d/g, function(v) {          return string.fromcharcode(v.charcodeat(0) + 0x06c0);        });      }    });  });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.2.3/jquery.min.js"></script>    <div lang="fa">        <div>some text here , 1234567890</div>        <table>        <tr>          <td id="apikey">123qwe456qwe123</td>          <td id="apikey">456ert456</td>        </tr>        </table>        </div>

your ids need unique.

use class , .not or :not

$(window).load(function() {    $("[lang='fa']").find("*").andself().not(".apikey").contents().each(function() {      if (this.nodetype === 3) {        this.nodevalue = this.nodevalue.replace(/\d/g, function(v) {          return string.fromcharcode(v.charcodeat(0) + 0x06c0);        });      }    });  });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.2.3/jquery.min.js"></script>    <div lang="fa">        <div>some text here , 1234567890</div>        <table>        <tr>          <td class="apikey">123qwe456qwe123</td>          <td class="apikey">456ert456</td>        </tr>        </table>        </div>


Comments

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -