开发者

Label behind the textbox

开发者 https://www.devze.com 2022-12-31 16:12 出处:网络
I am using the following sample to display text in the background of the textbox. It is working fine too.http://attardi.org/labels/

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 lik开发者_如何学编程e it expanded but while typing the actual size is not expanded. I want to type text till 600px.

Geetha.


$(".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.

0

精彩评论

暂无评论...
验证码 换一张
取 消