Есть у кого-нибудь хороший вариант кода? Вот этот
<script>
// функция подсчета количества строк
function countLines(strtocount, cols) {
var hard_lines = 1;
var last = 0;
while ( true ) {
last = strtocount.indexOf("\n", last+1);
hard_lines ++;
if ( hard_lines == 5) break;
if ( last == -1 ) break;
}
var soft_lines = Math.ceil(strtocount.length / (cols-1));
var hard = eval("hard_lines " + unescape("%3e") + "soft_lines;");
if ( hard ) soft_lines = hard_lines;
return soft_lines;
}
// функция вызывается при каждом нажатии клавиши в области ввода текста
function ResizeTextArea(the_form,min_rows) {
the_form.rows = Math.max(min_rows,countLines(the_form.value,the_form.cols) +1);
}
</script>
не супер. Почему-то из-за этого кода перестает работать этот
<script>
(function($){
/* использование: <a class='scrollTop' href='#' style='display:none;'></a>
------------------------------------------------- */
$(function(){
var e = $(".scrollTop");
var speed = 500;
e.click(function(){
$("html:not(:animated)" +( !$.browser.opera ? ",body:not(:animated)" : "")).animate({ scrollTop: 0}, 500 );
return false; //важно!
});
//появление
function show_scrollTop(){
( $(window).scrollTop()>300 ) ? e.fadeIn(600) : e.hide();
}
$(window).scroll( function(){show_scrollTop()} ); show_scrollTop();
});
})(jQuery)
</script>