javascript - Words highlight when mouse is over -
I need some help How to highlight a word in my own paste text is possible.
Like I have & lt; Textarea & gt; & Lt; / Textarea & gt;
, where I can paste text or just one sentence and when the mouse is more than one word it is being highlighted here by Damovisa:
$ 1 & lt; / span & gt; "));}); // Tie each span $ ('p span'). Focus (function () {$ ('# word'). Text ($ (this) .css ('background-color', '# ffff66') .text ());}, function () {$ (' # Word '). Text (' '); $ (this) .css (' background-color ',' ');});
Regards
Man, you guys are fast !! - Anyhow, as I had made it (fun), it can also share it
- Yes, Johnson responds well - here's the content to be friendly Usage
Demo
Perhaps an extra here is picking up on being able to change the paste / text.
HTML:
& lt; Div class = "wordscontainer" contenteditable = "true" & gt; Paste the word here ... & lt; / Div & gt; & Lt; Div id = "word" & gt; & Lt; / Div & gt;
JS
function set () {/ we re-binding * / $ ('text ());} , Function (.) (.) (). ) {$ ('# Words'). Lesson (''); $ (This). Css ('background-color', '');}); } $ (". Wordscontainer") key (function () {var $ this = $ (this); $ this.html ($ this.text (). Replace (/ \ b (\ w +) \ b / g, "& Lt; span & gt; $ 1 ")); sethover ();});
Display / Demo
.wordscontainer {padding: 10px; Margins: 10px; Border: 2px solid # 999; Minute-height: 400px; } #world {padding: 10px margin: 10px; Font-size: 20px; }
Comments
Post a Comment