Add tags and text to user's selected text Javascript/JQuery -


i have big editable table may contain other tables , need add tags selected text, example <strong> or simple text. here table , button:

<table id="list">   <tr id="row0"><th colspan="2">header</th></tr>   <tr id="row1"><td id="row1col1"  contenteditable="true" >row 1, column 1 </td><td id="row1col2"  contenteditable="true" >row 1, column 2</td></tr>   <tr id="row2"><td id="row2col1"  contenteditable="true" >row 2, column 1</td><td id="row2col2"  contenteditable="true" >row 2, column 2</td></tr>   <tr id="row3"><td id="row3col1"  contenteditable="true" >row 3, column 1</td><td id="row3col2"  contenteditable="true" ><table> ///some elements without id/// </table></td></tr> </table> <input type="button" id="bestrong" value="make strong" /> 

i want when user highlights text , clicks on #bestrong before , after selection being added tags <strong>, in richtextoxes.

i'm new javascript/jquery, searched lot don't have required knowledge yet understand how this. retrieve selected text this:

 var seltxt=document.getselection().text; 

last thing: read on web uses id,class,or gerarchical css' selector identify selected text position, there isn't way trick without them?


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -