html TextRange的使用
来源:互联网 发布:雅虎股票数据接口 编辑:程序博客网 时间:2024/05/17 22:02
<textarea id="target">fdajklfj al</textarea>
<p><button id="btn">插入话题</button></p>
<script language="javascript">
var $ = function (id) {
return document.getElementById(id);
};
$("btn").onclick = function () {
var con = "请在这里输入自定义话题";
//转载文字
$("target").value += "#" + con + "#";
var l = $("target").value.length;
//创建选择区域
if ($("target").createTextRange) {//IE浏览器
var range = $("target").createTextRange();
// range.moveEnd("character", -l)
//range.moveStart("character",-l)
range.moveEnd("character", l - 1);
range.moveStart("character", l - 1 - con.length);
range.select();
} else {
$("target").setSelectionRange(l - 1 - con.length, l - 1); // 一共13 range(1,12); 1< =12
$("target").focus();
}
};
</script>
<p><button id="btn">插入话题</button></p>
<script language="javascript">
var $ = function (id) {
return document.getElementById(id);
};
$("btn").onclick = function () {
var con = "请在这里输入自定义话题";
//转载文字
$("target").value += "#" + con + "#";
var l = $("target").value.length;
//创建选择区域
if ($("target").createTextRange) {//IE浏览器
var range = $("target").createTextRange();
// range.moveEnd("character", -l)
//range.moveStart("character",-l)
range.moveEnd("character", l - 1);
range.moveStart("character", l - 1 - con.length);
range.select();
} else {
$("target").setSelectionRange(l - 1 - con.length, l - 1); // 一共13 range(1,12); 1< =12
$("target").focus();
}
};
</script>
0 0
- html TextRange的使用
- DHTML --TextRange对象的使用
- TextRange对象与Range对象的使用
- TextRange对象,动态HTML(DHTML)的高级特性
- 使用TextRange对象
- 使用TextRange获取输入框中光标的位
- 使用TextRange获取输入框中光标的位置
- 使用TextRange获取输入框中光标的位置
- 使用TextRange获取输入框中光标的位置
- TextRange
- (转)使用TextRange对象
- textRange的findText()方法详解
- 比较深入的认识一下textrange
- TextRange对象的学习(一)
- Range、Selection、TextRange对象的区别与关系
- TextRange对象
- TextRange对象
- IE和FF下关于selection和textRange的一些资料
- 深度学习算法实践2---线性代数和Numpy的使用
- poj1521
- Android5.0特性
- #123 Word Search
- SpringMVC @RequestBody接收Json对象字符串
- html TextRange的使用
- Flume学习笔记(二)问题整理
- uclibc,eglibc,glibc之间的区别和联系
- 安卓监听和修改软键盘右下角按钮
- linux下NFS文件共享的介绍和使用
- C#泛型
- C语言中for语句执行顺序
- 【华为 OJ 】求int型数据在内存中存储时1的个数
- http发送json格式数据请求 demo示例