tags:

views:

39

answers:

1

Hi All,

I am using the following sample to display text in the background of the textbox. It is working fine too. http://attardi.org/labels/

Problem:

I want to increase the text box with. The box looks like it expanded but while typing the actual size is not expanded. I want to type text till 600px.

Geetha.

+1  A: 
$(".input :input").keypress(function(){
    var o = $(this); 
    var s = $("<span></span>").html(o.val()).addClass('placeholder').css('left', '-9999px'); 
    if (o.outerWidth() < 600) {
        o.parent().append(s); 
        if (s.outerWidth() > o.outerWidth()){
            o.css("width", s.outerWidth()); 
        }
        $("span.placeholder").remove();
    }
});

I tested this and it seems to work pretty good. not bad for 7 minutes of code/test/burn.

Gabriel
Thank You so much. Excellent work.
Geetha
I am still goofing around with something, trying to get it to shrink when you backspace.... really fun issue/question. And a nice page to boot.
Gabriel