您现在的位置是:首页 > 技术杂文前端杂文
JS控制textareat标签自应适
阿龙2021-12-09【前端杂文】人已围观
$(function(){
$.fn.autoHeight = function(){
function autoHeight(elem){
elem.style.height = 'auto';
elem.scrollTop = 0; //防抖动
elem.style.height = elem.scrollHeight + 'px';
}
this.each(function(){
autoHeight(this);
$(this).on('keyup', function(){
autoHeight(this);
});
});
}
$('textarea[autoHeight]').autoHeight();
})
<textarea autoHeight="true" readonly="readonly" ></textarea>
Tags:textareat
很赞哦! ()
随机图文
JS将24小时格式转换为12小时
var dt = new Date();var hours = dt.getHours(); // 以24小时格式给出值var minutes = dt.getMinutes() ;var finalTime = "Time - " + hours + ":" + minutes;//finalTimeCSS盒子水平居中的六种方法
方法一:定位居中.child{position:absolute;top:50%;left:50%;margin-top:-50px;margin-left:-50px;}方法二:margin居中.child{position:absolute;margin:auto;top:0;left:0;ri