javascript控制在光标位置插入文字适合表情的插入
在实现表情的插入时用到了。
<spanstyle="font-size:18px;"><html>
<head>
<scripttype='text/javascript'>
functiontest(str){
vartc=document.getElementById("mytextarea");
vartclen=tc.value.length;
tc.focus();
if(typeofdocument.selection!="undefined")
{
document.selection.createRange().text=str;
}
else
{
tc.value=tc.value.substr(0,tc.selectionStart)+str+tc.value.substring(tc.selectionStart,tclen);
}
}
</script>
</head>
<body>
<textarearows=5name=s1cols=27id="mytextarea">目的通过点击页面上的按钮button在textarea中的光标停留处插上文字</textarea>
<inputtype=buttononclick="test('这是需要加入的文字')"/>
</body>
</html>
</span>
热门推荐
10 感谢韩语老师祝福语简短
11 升职文案高级祝福语简短
12 花童结婚祝福语大全简短
13 向国庆送祝福语简短
14 什么寄语简短祝福语女生
15 客户回礼祝福语大全简短
16 女孩生日祝福语简短创意
17 家长回复节日祝福语简短
18 给外婆敬酒祝福语简短