How to change enable to disable in Td?

I have a question. I Have a table data

as like this

<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 I used to this jquery function

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

Now i want to

  1. if i click enable Button than change Enabled To Disabled Left and Right Both side

Link

Answers


For the sake of the answer I'll use your code, but just to let you 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/


Need Your Help

undefined reference to 'freeHeap'

c function reference undefined

I have encountered a problem when calling my freeHeap function inside of sortComp.c

Code not working on JS Fiddle

javascript jquery jquery-ui marionette jsfiddle

So I'm trying to showcase an issue I have in an application by providing a JS Fiddle, but now I have an xtra problem, my code won't work on JS Fiddle!

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.