javascript - Jquery selected value of highlighted text -
im trying create editor when highlight text on computer, jquery take selected value , throw tags around it, more specificity code or pre tags.
var selectedvalue = // set highlighted selection value $("#content").contents().find("body").append($("<pre></pre>").append(selectedvalue)) ;
i know how value between tags, need know how value.
well googling of few time , found out http://mark.koli.ch/2009/09/use-javascript-and-jquery-to-get-user-selected-text.html sure it.
example
response op comment
<script type="text/javascript" src="js/jquery.js"></script> <script type="text/javascript"> $(function() { var ifx = $('<iframe src="code/sample.html" height=200 width=200></iframe>').appendto(document.body); $(document.body).bind('mouseover', function() { var u_sel; if(window.getselection) { u_sel = ifx[0].contentwindow.getselection(); alert(u_sel); } }); }); </script>
javascript jquery
No comments:
Post a Comment