简体   繁体   English

文字框后面的标签

[英]Label behind the textbox

I am using the following sample to display text in the background of the textbox. 我正在使用以下示例在文本框的背景中显示文本。 It is working fine too. 它也工作正常。 http://attardi.org/labels/ 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. 我想输入文字直到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. 对于7分钟的代码/测试/刻录,还不错。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM