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.
$(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
Post a Comment