<html>
<head></head>
<body>
<table>
<tr>
<td onclick="document.all['txt'].select();alert(document.selection.createRange().text);">aaa</td>
</tr>
</table>
<input type="text" name="txt"/>
<input type="button" onclick="document.all['txt'].focus();alert(document.selection.createRange().text);"/>
</body>
</html>
<head></head>
<body>
<table>
<tr>
<td onclick="document.all['txt'].select();alert(document.selection.createRange().text);">aaa</td>
</tr>
</table>
<input type="text" name="txt"/>
<input type="button" onclick="document.all['txt'].focus();alert(document.selection.createRange().text);"/>
</body>
</html>
解决方案 »
- csdn论坛排行榜页面的特效是怎么弄的???
- 怎样使用户的屏幕焦点固定不变
- 大家好 , 求助一个问题,我公司网站中毒了病毒在网页的最后加了句话<script src="http:\\d%.asdf.."></script>
- System.IO.File.Exists检测文件是否存在.
- 这个判断,用js或jquery改怎么写?
- 请问:如何点击applet时,不显示开发者说明
- 请问有js可以控制不让浏览者点击“文件---另存为”!!!!!!!
- 怎么过滤信息
- 如何在iframe中禁止鼠标右键?急!
- 请问怎样设置一个网页中ActiveX的属性,条件是在ActiveX运行之前,请问有什么事件吗?
- 用js代码如何画一个多选择框或是按钮
- 求一个网址后缀提取的正则表达式
如果需要onclick触发,也可以先onmouseover时将选中的值先取出来。
如果文本框里的值是:abcde
我选中de,要把它替换成[ i ]de[ /i ]
你怎么换?
因为点的时候拿不到selection
所以不能用document.selection.createRange().text = ..
这种方式来换了。
你帮忙做一个示例吧,这么说实在不明白。