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 婆婆高寿祝福语大全简短