Partager l'article ! Jquery : Plugins textarea adjust auto: Fichier requis : Jquery.latest.js Utilisation : $("textarea").ajusttextarea(hauteur_minimale_du_ ...
Fichier requis : Jquery.latest.js
Utilisation : $("textarea").ajusttextarea(hauteur_minimale_du_textarea, hauteur_des_lignes);
jQuery.fn.ajusttextarea = function(minheight, lineheight) {
return this.each(function() {
object = $(this);
$(this).css("overflow","hidden");
$(this).css("resize","none");
$(this).attr("wrap","hard");
$(this).animate({height: minheight }, 200);
$(this).keyup(function(e) {
if ($(this).prop("scrollHeight") > minheight) {
if (e.keyCode == 8 || e.keyCode == 46) {
$(this).height($(this).prop("scrollHeight") - lineheight);
$(this).height($(this).prop("scrollHeight"));
} else if (e.ctrlKey || e.keyCode == 13)
if ($(this).prop("scrollHeight") > $(this).height())
$(this).animate({height: $(this).prop("scrollHeight") },
200);
}
});
});
};
Pour tous question merci de commenter le poste.