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 ...
随机推荐
- java.sql.SQLException: ORA-00911: 无效字符 解决方案
在使用java执行sql时,抛出的这样一个Oracle异常,最后发现是sql语句末尾有一个分号导致,例如:sql="select * from tl_demo;" .删除" ...
- JDBC 异常特殊原因 (数据库只读解决办法)
JDBC 异常特殊原因 有时候并不是因为程序写的有问题 ,是因为 数据库只读 在sqlserver2005中附加数据库时,附加的数据库会变成只读的,只能进行查询操作. 解决方法: 1 打开Sq ...
- 帝国cms7.0整合百度编辑器ueditor教程
帝国cms7.0整合百度编辑器ueditor教程开始 1.根据自己使用的帝国cms版本编码下载对应的ueditor版本 下载地址 http://ueditor.baidu.com/website/do ...
- DataTables给每一列添加下拉框搜索
$(document).ready(function() { $('#example').DataTable( { initComplete: function () { var api = this ...
- mac/unix系统:C++实现一个端口扫描器
在比较早以前,我用过S扫描器, 以及大名鼎鼎的nmap扫描器, 可以快速扫描某个主机开放的端口, 今天使用C实现这样一个软件, 编译环境为Mac, 系统版本10.11.6: #include < ...
- $(function(){})与(function($){....})(jQuery)的区别
$(function(){}); 全写为 $(docunemt).ready(function(){ }); 意义为在DOM加载完毕后执行ready()方法 (function($){....})(j ...
- [UVA] 11991 - Easy Problem from Rujia Liu? [STL应用]
11991 - Easy Problem from Rujia Liu? Time limit: 1.000 seconds Problem E Easy Problem from Rujia Liu ...
- 使用AlarmManager进行定时任务处理
1:UploadingService.java package com.example.service; import com.example.broadcast.AlarmReceiver; imp ...
- HTTP 错误 500.21 - Internal Server Error 处理程序“PageHandlerFactory-ISAPI-4.0_32bit”在其模块
问题: 系统是win7.今天把我做过的项目发布后,在IIS上运行时一直出现一个错误,HTTP 错误500.21-Internal Server Error.处理程序“PageHandlerFactor ...
- 一颗 45nm CPU的制造过程
沙子 :硅是地壳内第二丰富的元素,而脱氧后的沙子(尤其是石英)最多包含25%的硅元素,以二氧化硅(SiO2)的形式存在,这也是半导体制造产业的基础. 硅熔炼: 12英寸/300毫米晶圆级,下同.通过多 ...