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

前端 未结 3 1871
南笙
南笙 2020-12-09 08:59

I have a textarea with 5 lines. I want to show only one line and on focus it should show remaining 4 lines.

3条回答
  •  温柔的废话
    2020-12-09 09:57

    You can try something like this:

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

    where moo is your textarea.

提交回复
热议问题