jQuery to hide substring in a table cell -
i want hide substring in table cell. let's assume table looks this:
<div id="table"> <table> <tr> <td> blah </td> <td> blah [100, 100]</td> <td> blah [130, 70]</td> </tr> </table> </div> how can use jquery (and css) hide [100,100] part of cell 2 , [130, 70] part of cell 3?
i found solution in answer similar problem:
<div class="text">good stuff hide me</div> <div class="text">great stuff hide me</div> <div class="text">best stuff hide me</div> $('div.text').html(function (i, t) { return t.replace('hide me', '<span class="hidden">hide me</span>'); }) but think need regex solution since contents of [ ] part can different? or there better iea?
you correct needing regex. should work:
<div class="text">good stuff [100]</div> <div class="text">great stuff[100,010]</div> <div class="text">best stuff[70, 130, 180]</div> $('div.text').html(function (i, t) { return t.replace(/\[.*\]/g, ''); })
Comments
Post a Comment