How to change the number of rows in the textarea using jQuery

吃可爱长大的小学妹 提交于 2019-11-28 09:02:54

You can try something like this:

     $(document).ready(function(){

    $('#moo').focus(function(){
        $(this).attr('rows', '4');
    });
});

where moo is your textarea.

jQuery(function($){
  $('#foo').focus(function(){
    $(this).attr('rows',5);
  }).blur(function(){
    $(this).attr('rows',1);
  });
});

Or, using less jQuery, less typing, and getting a hair more performance:

jQuery(function($){
  $('#foo')
    .focus(function(){ this.rows=5 })
    .blur( function(){ this.rows=1 });
});

Try this

$('#textboxid').focus(function()
    {
       $(this).animate({'height': '185px'}, 'slow' );//Expand the textarea on clicking on it
       return false;
     });
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!