Javascript 更改高度并向下滑动文本区域
在点击一个textarea时,我需要它将textarea的高度更改为60px,同时向下滑动,使其看起来像一个平滑的动画 以下是JSFIDLE: HTML:Javascript 更改高度并向下滑动文本区域,javascript,jquery,html,css,twitter-bootstrap,Javascript,Jquery,Html,Css,Twitter Bootstrap,在点击一个textarea时,我需要它将textarea的高度更改为60px,同时向下滑动,使其看起来像一个平滑的动画 以下是JSFIDLE: HTML: 谢谢。:) 什么样的 您需要的方法称为,并且有很好的文档记录 现在为您的小提琴演示动画方法加上focus()和blur()方法: 它作为动画效果更好 $("textarea").on('focus',function (e, ui) { $(this).animate({ height: "60px" },
谢谢。:) 什么样的
您需要的方法称为,并且有很好的文档记录 现在为您的小提琴演示动画方法加上focus()和blur()方法:
它作为动画效果更好
$("textarea").on('focus',function (e, ui) {
$(this).animate({
height: "60px"
}, 1500);
});
是否有可能使文本区域实际上缓慢而不是立即向下滑动?哦,我现在明白你的意思了。是的,使用动画。将this.css更改为this.animate({height:“60px”},1000);(对不起,我现在手机上的格式不好)@ErikDown的大小为60px。
$('#comment').click(function() {
$(this).css('height', '60px');
});
jQuery(document).ready(function ($){
var element = $('.well textarea');
var orig_height = element.height();
var new_height = 60;
// onfocus event handler
element.focus(function (){
$(this).animate({height: new_height + 'px'});
});
// onblur event handler
element.blur(function (){
$(this).animate({height: orig_height + 'px'});
});
});
$("textarea").on('focus',function (e, ui) {
$(this).animate({
height: "60px"
}, 1500);
});
$('#comment').click(function () {
$(this).fadeIn(3000, function() {
$(this).css('height', '60px');
});
$(this).focusout(function() {
$(this).css('height', '20px');
});
});