html - How to replace text in first TD based on the values of table stored in other TD with JQuery? -


i have multiple tables stacked inside div container below:-

<div id="mycontent"  style="display: block;">       <table id="mytable" cellspacing="0" cellpadding="0" >         <tbody>           <tr>             <td style="padding-top: 10px;">               <table>                 <tbody>                   <tr>                     <td align="left">                       health care (id-20)                     </td>                   </tr>                   <tr>                     <td align="left">                       20 wisconsin ave</td>                   </tr>                   <tr>                     <td align="left">                       641.235.5900                     </td>                   </tr>                   <tr>                     <td align="left">                       no website                     </td>                   </tr>                 </tbody>               </table>             </td>             <td align="right">               <img src="images/phone.png" class="imgheader" >             </td>           </tr>         </tbody>       </table>       <table id="mytable" cellspacing="0" cellpadding="0">         <tbody>           <tr>             <td style="padding-top: 10px;">               <table >                 <tbody>                   <tr>                     <td align="left">housing (id-25)</td>                   </tr>                   <tr>                     <td align="left">                       n/a</td>                   </tr>                   <tr>                     <td align="left">                       641.255.3884                     </td>                   </tr>                   <tr>                     <td align="left">                       www.housingl.org                     </td>                   </tr>                 </tbody>               </table>             </td>             <td align="right">               <img src="images/phone.png" class="imgheader" >             </td>           </tr>         </tbody>       </table>       <table id="mytable" cellspacing="0" cellpadding="0" >         <tbody>           <tr>             <td style="padding-top: 10px;">               <table>                 <tbody>                   <tr>                     <td align="left">                       employment(id-35)</td>                   </tr>                   <tr>                     <td align="left">n/a</td>                   </tr>                   <tr>                     <td align="left">                       641.743.0500                     </td>                   </tr>                   <tr>                     <td align="left">                       http://www.noexperience.org                     </td>                   </tr>                 </tbody>               </table>             </td>             <td align="right">               <img src="images/phone.png" class="imgheader" >             </td>           </tr>         </tbody>       </table>     </div> 

i trying run condition find td n/a , remove contents on first td of table. precisely, remove text displayed between brackets in first td i.e. "(id-25)" if of text in table "n/a". how can accomplish that? support appreciated!!!

try:

$('td:contains("n/a")').each(function () {     if ($(this).children().length == 0) {         $(this).closest('table').find('td').first().text($(this).closest('table').find('td').first().text().replace(/\(.*\)/ig, '()'));     } }); 

jsfiddle example


Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -