首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

询问DIV的有关问题,50分送上

2012-01-05 
询问DIV的问题,急急急急急,50分送上比如有一个文本框和有一个div我想实现单击div取得文本框中选中的文本请

询问DIV的问题,急急急急急,50分送上
比如有一个文本框和有一个div
我想实现单击div取得文本框中选中的文本
请问怎么做

代码如下
<input   id= "Text1 "   type= "text "   />

<div   onclick= "alert(document.selection.createRange().text); "> 单击 </div>

<button   onclick= "alert(document.selection.createRange().text); "> </button>

用按钮就可以
但是用div就不行
不知道如何实现

[解决办法]
改成mousedown事件就好了

<input id= "Text1 " type= "text " />

<div onmousedown= "alert(document.selection.createRange().text); "> 单击 </div>

热点排行