td move to left

Hi,

In the following code:
html part

<table>
    <tr>
        <td class="cerrado">Cerrado</td><td>test</td>
        <td class="cerrado">Cerrado</td><td>test2</td>
    </tr>
    <tr>
        <td class="cerrado">Cerrado</td><td>test3</td>
        <td class="cerrado">Cerrado</td><td>test4</td>
    </tr>
</table>

$(".cerrado").click(function () {
    var inputTxt = $(this).prev('input').val()
    if ($(this).hasClass('contador')) {
        $(this).removeClass('contador');

        $(this).prev('input').remove();
        $(this).text(inputTxt);
    } else {
        $(this).addClass('contador');
        $('<input type="text" value="' + $(this).text() + '" />').insertBefore($(this));
        $(this).html('<button>GUARDAR</button>');
    }
});

Open in new window


my problem is that when i press a td with the class cerrado, the table add the button guardar in a new td, i need to be in the same td after the input box, how i can change that? see ID: 40772958, my last question, thank you!
LVL 1
joyacv2Asked:
Who is Participating?
 
Tom BeckCommented:
You could just remove the button styling.

http://jsfiddle.net/htq1xjdj/2/
0
 
Tom BeckCommented:
0
 
joyacv2Author Commented:
Hi Tom,

When i click the input to start typing, then the input disappear and convert to only a td
0
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

 
Tom BeckCommented:
Yes I know. Still working on it.
0
 
joyacv2Author Commented:
ok, no problem, i wait, thank you!
0
 
Tom BeckCommented:
Does this work for you?

http://jsfiddle.net/htq1xjdj/1/
0
 
joyacv2Author Commented:
Hi,

the logic works, but i need that the text is a text inside a td, not a button, any idea?
0
 
Tom BeckCommented:
Just curious though. If it's not a button or a link, how do your users know to click on it?
0
 
joyacv2Author Commented:
perfect solution!

My users know which fields needs to be modified, so they usually knows that a td is clickable! Your solution is perfect!
0
 
Tom BeckCommented:
Glad it worked for you. Thanks for the points.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.