The following code snippet gets the selected text only from the Text box and then this text is processed and updated to the text box.
The above function replaces all a’s in the selected text with b’s.
The above code uses two ways to get the selected text. The two methods are for different browsers;Mozilla, IE.
Here is a demo code:
Copy this code to an file and name it as Default.Html. Double click the file, it will open in a browser. Rest of the instructions are given on the page.