javascript - Applying a style to text that I double click? -
edited reword:
i have input box
<input type="text" id="some_id" />
i enter text in in browser:
here text!
now suppose double click on word "my", can i:
capture value? yes, answer below.
can style in place in text input make bold or highlight?
in text input after double click end looking like:
here my text!
if want word selected (via double click default behaviour)
$('input').dblclick(function() { $(this).addclass(yourclass); alert(getselected()); });
using getselected function found http://mark.koli.ch/2009/09/use-javascript-and-jquery-to-get-user-selected-text.html
getselected = function(){ var t = ''; if(window.getselection){ t = window.getselection(); }else if(document.getselection){ t = document.getselection(); }else if(document.selection){ t = document.selection.createrange().text; } return t; }
applying class selected text.. don't know if possible
Comments
Post a Comment