javascript - scan table data and replace certain string inside html table -


i have following table

<table class="data">     <thead>     <tr>         <th>1</th>         <th>2</th>         <th>3</th>     </tr>     </thead>     <tbody>     <tr>         <td>             1 data         </td>         <td>             2 data         </td>         <td>             123456789123         </td>     </tr>     </tbody> </table> 

how can dynamically scan table , replace values in third table body td values information 123456789123 stored.

this information should placed character on string location so

<td> 123456789123 </td> should <td> 12345678*12* </td>

please find below code block need, have added 1 specific class td want modify value.

$( document ).ready(function() {    $('.value_td').each(function(key, ele){              // getting original value      var original_val = $(ele).text().trim();            // can change logic here modify text        var new_value = original_val.substr(0, 8) + '*' + original_val.substr(9, 2) + '*';              // replacing new value      $(ele).text(new_value);    });  });
<table class="data">      <thead>      <tr>          <th>1</th>          <th>2</th>          <th>3</th>      </tr>      </thead>      <tbody>      <tr>          <td>              1 data          </td>          <td>              2 data          </td>          <td class="value_td">              123456789123          </td>      </tr>      </tbody>  </table>

js fiddle


Comments

Popular posts from this blog

Java 3D LWJGL collision -

methods - python can't use function in submodule -

c# - ErrorThe type or namespace name 'AxWMPLib' could not be found (are you missing a using directive or an assembly reference?) -