2010-12-11 4 views

Répondre

25

Vous pouvez essayer quelque chose comme ceci:

 $(document).ready(function(){ 

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

où moo est votre textarea.

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

Ou, en utilisant moins jQuery, moins de frappe, et d'obtenir un poil plus de performance:

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

Essayez cette

$('#textboxid').focus(function() 
    { 
     $(this).animate({'height': '185px'}, 'slow');//Expand the textarea on clicking on it 
     return false; 
    }); 
+0

: S'il vous plaît être plus descriptif de votre solution. Reportez-vous à: [Comment répondre] (http://stackoverflow.com/questions/how-to-answer) – askmish

Questions connexes