如何获取选中的值????

解决方案 »

  1.   

    给你提供一个参考吧 http://www.cssdemon.me/?p=335
      

  2.   

    <input id="test" type="button" value="test"></input>
    <div contenteditable="true" id="textarea" style="width:100px;height:100px;border:1px solid"></div>
    $(function() {
        $("#test").bind("click",function() {
             var selectTxt;  
            if(window.getSelection){
              
              selectTxt=window.getSelection();  
            }else if(document.selection){ 
              
              selectTxt=document.selection.createRange().text;  
                  }  
              alert(selectTxt);
        });
    });
    使用div模拟textarea即可。
      

  3.   

    http://www.zhangxinxu.com/study/201104/range-miniblog-insert-topic.html
    找到个你需要的完整示例,满足你的所有要求。