textarea 的最大高度以及最小高度
<script type="text/javascript">
$(function(){
$("#textarea3").textareaAutoHeight({ minHeight:25, maxHeight:69 });
})
//最小高度和最大高度默认
//最大高度为100px
//$("#textarea2").textareaAutoHeight({ maxHeight:100 });
//最小高度为50px,最大高度为200px
//$("#textarea3").textareaAutoHeight({ minHeight:50, maxHeight:200 });
$.fn.extend({
textareaAutoHeight: function (options) {
this._options = {
minHeight: 0,
maxHeight: 1000
}
this.init = function () {
for (var p in options) {
this._options[p] = options[p];
}
if (this._options.minHeight == 0) {
this._options.minHeight=parseFloat($(this).height());
}
for (var p in this._options) {
if ($(this).attr(p) == null) {
$(this).attr(p, this._options[p]);
}
}
$(this).keyup(this.resetHeight).change(this.resetHeight)
.focus(this.resetHeight);
}
this.resetHeight = function () {
var _minHeight = parseFloat($(this).attr("minHeight"));
var _maxHeight = parseFloat($(this).attr("maxHeight"));
if (!$.browser.msie) {
$(this).height(0);
}
var h = parseFloat(this.scrollHeight);
h = h < _minHeight ? _minHeight :
h > _maxHeight ? _maxHeight : h;
$(this).height(h).scrollTop(h);
if (h >= _maxHeight) {
$(this).css("overflow-y", "scroll");
}
else {
$(this).css("overflow-y", "hidden");
}
}
this.init();
}
});
</script>
textarea 的最大高度以及最小高度的更多相关文章
- [LeetCode] Minimum Height Trees 最小高度树
For a undirected graph with tree characteristics, we can choose any node as the root. The result gra ...
- CSS+DIV问题!DIV的最小高度问题!
DIV层的最小高度问题!就是一个DIV有个最小高度,但是如果DIV层中的内容很多,DIV的高度会根据内容而进行拉长!要求IE6.IE7还有firefox都要兼容!我试了很多网上的方法都不好用!请测试后 ...
- 外部div自适应内部标签的高度,设置最小高度、最大高度
一.div自适应高度:在前端开发中经常需要让外层的div自动适应内部标签和内容的高度,内部标签可能是<div>.<ul>.<ol>或者文字等各种内容.造成外层的di ...
- ie67 设置最小宽度最小高度
1.最小宽度 min-width:1003px; _width:expression((document.documentElement.clientWidth||document.body.clie ...
- div有最小高度且自适应高度
DIV最小高度且自适应高度 在IE6中,如果子容器的高度超过父容器的时候,父容器会被子容器撑开,所以我们可以直接设置一个height的高度值即可.但是在IE7和firefox就不行了,它不会自动撑 ...
- 解决ie6支持最大高度最小高度的方法
1.IE6支持max-height解决方法 IE6支持最大高度解决CSS代码:.yangshi{max-height:1000px;_height:expression((document.docum ...
- css ie6最小高度问题
最小高度问题: 这个最小高度 min-height:的问题,因为min-height:只在IE7\FF中起作用.至于这个IE6死活就是不认.而我这个页面又必需得用这个最小高度来定. 但头痛的是I ...
- [Swift]LeetCode310. 最小高度树 | Minimum Height Trees
For an undirected graph with tree characteristics, we can choose any node as the root. The result gr ...
- 最小高度的树 Minimum Height Trees
2018-09-24 12:01:38 问题描述: 问题求解: 毫无疑问的一条非常好的题目,采用的解法是逆向的BFS,也就是从叶子节点开始遍历,逐步向中心靠拢,最终留下的叶子节点就是答案. publi ...
随机推荐
- 除去内容中的HTML代码方法
显示内容时,需要截取部分,而不要全部显示.在截取时,会出现这样的情况: 截取一定量的字符串后,可能会把未关闭的表格HTML代码留下来,最終导致界面受影响, 下面的是C#解决办法: public str ...
- txt 分割程序
网上有很多 分割程序 ,但是他们都没有满足实际的用户要求 ,大家当然是希望看文章小说 一章节一章节的看 并非是那些传统意义上的按照文件的大小切割 所以 我特写本文研究下 这个简单的算法该怎样设计 说白 ...
- mysql查询分组归类函数-group_concat,通常与group_by一起使用
select a.`name`,group_concat(b.name SEPARATOR'.') as persons from `group` as a,`person` as b,`person ...
- lightOJ1370 欧拉函数性质
D - (例题)欧拉函数性质 Crawling in process... Crawling failed Time Limit:2000MS Memory Limit:32768KB ...
- 快速搭建Android 开发环境-使用ADT Bundle
一.搭建Android开发环境 近日要学Android开发基础,就着手搭建Windows下的Android开发环境. 找了一些相关的博文参考,基本上都是要分别下载和安装JDK, Eclipse, An ...
- IFS解惑
一.IFS 介绍 Shell 脚本中有个变量叫 IFS(Internal Field Seprator) ,内部域分隔符.完整定义是The shell uses the value stored in ...
- NSDate简单的使用
NSDateFormatter *dateFormtter=[[NSDateFormatter alloc] init]; [dateFormtter setDateFormat:@"yyy ...
- memcached在Windows下的安装
memcached简介详情请谷歌.这里介绍如何在windows下安装. 1.下载 下载地址:http://download.csdn.net/detail/u010562988/9456109 ...
- 通过IIS发布站点和VS2012自带发布网站
vs2012通过IIS发布站点 http://jingyan.baidu.com/article/0964eca2d7beeb8285f536bd.html 用VS2012自带发布网站 http:// ...
- VC6-Win7下VC++6.0打开多个工程的设置
在Win7操作系统下,如果是以Administrator登陆,则VC6.0打开工程文件的时候,不能同时打开多个工程文件,后打开的工程会将前一个工程close掉,这样,VC6.0只能出现一个进程.在xp ...