jquery - How to change enable to disable in Td? -


i have question. have table data

as

<table>     <tr>         <td>enabled</td>         <td><button class="js-enabled">desabled</button></td>     </tr>      <tr>          <td>desabled</td>          <td><button class="js-enabled">enabled</button></td>     </tr>      <tr>         <td>enabled</td>         <td><button class="js-enabled">desabled</button></td>     </tr>      <tr>          <td>desabled</td>          <td><button class="js-enabled">enabled</button></td>     </tr>      <tr>         <td>enabled</td>         <td><button class="js-enabled">desabled</button></td>     </tr>      <tr>          <td>desabled</td>          <td><button class="js-enabled">enabled</button></td>     </tr> </table> 

and used jquery function

$('.js-enabled').click(function(){             $(this).replacewith('<button class="btn btn-success">active</button>');                  });  

now want to

  1. if click enable button change enabled disabled left , right both side

link

for sake of answer i'll use code, let know, it's spelled 'disabled'.

$('.js-enabled').click(function(){     var button = $(this);     var label = $(this).parent().prev('td');      button.text() == 'desabled' ? button.text('enabled') : button.text('desabled');     label.text() == 'desabled' ? label.text('enabled') : label.text('desabled'); });  

http://jsfiddle.net/egdze/2/


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -