【发布时间】:2011-05-23 23:05:29
【问题描述】:
我有一个 5 行的文本区域。我只想显示一行,并且在焦点上应该显示剩余的 4 行。
【问题讨论】:
标签: javascript jquery textarea jquery-events
我有一个 5 行的文本区域。我只想显示一行,并且在焦点上应该显示剩余的 4 行。
【问题讨论】:
标签: javascript jquery textarea jquery-events
你可以试试这样的:
$(document).ready(function(){
$('#moo').focus(function(){
$(this).attr('rows', '4');
});
});
moo 是你的文本区域。
【讨论】:
jQuery(function($){
$('#foo').focus(function(){
$(this).attr('rows',5);
}).blur(function(){
$(this).attr('rows',1);
});
});
或者,使用更少的 jQuery,更少的输入,并获得更多的性能:
jQuery(function($){
$('#foo')
.focus(function(){ this.rows=5 })
.blur( function(){ this.rows=1 });
});
【讨论】:
试试这个
$('#textboxid').focus(function()
{
$(this).animate({'height': '185px'}, 'slow' );//Expand the textarea on clicking on it
return false;
});
【讨论】: