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.
精彩评论