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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
Tom BeckCommented:
Yes I know. Still working on it.
0
OWASP: Forgery and Phishing

Learn the techniques to avoid forgery and phishing attacks and the types of attacks an application or network may face.

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:
You could just remove the button styling.

http://jsfiddle.net/htq1xjdj/2/
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
jQuery

From novice to tech pro — start learning today.