Ich habe ein Textfeld mit 5 Zeilen. Ich möchte nur eine Zeile zeigen und im Fokus sollte es die restlichen 4 Zeilen anzeigen.Wie ändere ich die Anzahl der Zeilen im Textbereich mit jQuery
19
A
Antwort
25
Sie können so etwas wie dies versuchen:
$(document).ready(function(){
$('#moo').focus(function(){
$(this).attr('rows', '4');
});
});
wo moo ist Ihre Textarea.
6
jQuery(function($){
$('#foo').focus(function(){
$(this).attr('rows',5);
}).blur(function(){
$(this).attr('rows',1);
});
});
Oder mit weniger jQuery, weniger tippen, und immer ein Haar mehr Leistung:
jQuery(function($){
$('#foo')
.focus(function(){ this.rows=5 })
.blur(function(){ this.rows=1 });
});
0
Versuchen Sie, diese
$('#textboxid').focus(function()
{
$(this).animate({'height': '185px'}, 'slow');//Expand the textarea on clicking on it
return false;
});
: Bitte beschreibe über Ihre Lösung. Siehe: [Antwort] (http://stackoverflow.com/questions/how-to-answer) – askmish