jquery----TextArea高度自适应
来源:互联网 发布:windows tracert 实现 编辑:程序博客网 时间:2024/06/04 14:34
//最小高度和最大高度默认
02
$(
"#textarea1"
).textareaAutoHeight();
03
//最大高度为100px
04
$(
"#textarea2"
).textareaAutoHeight({ maxHeight:100 });
05
//最小高度为50px,最大高度为200px
06
$(
"#textarea3"
).textareaAutoHeight({ minHeight:50, maxHeight:200 });
07
08
$.fn.extend({
09
textareaAutoHeight:
function
(options) {
10
this
._options = {
11
minHeight: 0,
12
maxHeight: 1000
13
}
14
15
this
.init =
function
() {
16
for
(
var
p
in
options) {
17
this
._options[p] = options[p];
18
}
19
if
(
this
._options.minHeight == 0) {
20
this
._options.minHeight=parseFloat($(
this
).height());
21
}
22
for
(
var
p
in
this
._options) {
23
if
($(
this
).attr(p) ==
null
) {
24
$(
this
).attr(p,
this
._options[p]);
25
}
26
}
27
$(
this
).keyup(
this
.resetHeight).change(
this
.resetHeight)
28
.focus(
this
.resetHeight);
29
}
30
this
.resetHeight =
function
() {
31
var
_minHeight = parseFloat($(
this
).attr(
"minHeight"
));
32
var
_maxHeight = parseFloat($(
this
).attr(
"maxHeight"
));
33
34
if
(!$.browser.msie) {
35
$(
this
).height(0);
36
}
37
var
h = parseFloat(
this
.scrollHeight);
38
h = h < _minHeight ? _minHeight :
39
h > _maxHeight ? _maxHeight : h;
40
$(
this
).height(h).scrollTop(h);
41
if
(h >= _maxHeight) {
42
$(
this
).css(
"overflow-y"
,
"scroll"
);
43
}
44
else
{
45
$(
this
).css(
"overflow-y"
,
"hidden"
);
46
}
47
}
48
this
.init();
49
}
50
});
0 0
- jquery----TextArea高度自适应
- jquery实现textarea高度自适应
- jquery实现textarea 高度自适应
- jQuery实现<textarea>高度自适应,适用于td中的textarea
- textarea自适应高度
- textarea自适应高度
- textarea自适应高度
- textarea自适应高度
- textarea自适应高度
- textarea高度自适应
- textarea高度自适应
- textarea自适应高度
- textarea高度自适应
- textarea自适应高度
- textarea的高度自适应
- textarea 高度自适应
- textarea自适应高度
- textarea 高度自适应
- MPU6050的一些问题及解决办法
- Android文本的测量和绘制
- 利用数组元素交换技术来实现界面的翻页滑动效果
- Jade - 模板引擎
- Builder Pattern In Android
- jquery----TextArea高度自适应
- ARM Cortex 架构简介
- Uibutton 左对齐
- JAVA hashmap的用法 2009-04-14 16:04546233guo | 分类:JAVA相关 | 浏览25411次 1.加入元素 2.遍历这个map 3.移除元素
- js 知识
- bat批量处理压缩包,复制
- Flashcache
- 设计模式之工厂三姐妹
- IQueryable与IEnumberable的区别