- Overview
- Documents
jQuery.selection is a jQuery plugin that operate selection text/caret. You can get selection text/caret position information or get selected text, replace/insert selected text.
Source: madapaja.github.io
Jun 20, 2014 in Text Editor 4813 views
jQuery.selection is a jQuery plugin that operate selection text/caret. You can get selection text/caret position information or get selected text, replace/insert selected text.
Source: madapaja.github.io
1. INCLUDE JS FILES
<script src="http://code.jquery.com/jquery-latest.js"></script> <!-- Load jQuery.selection plugin--> <script src="jquery.selection.js"></script>
2. HTML
<input type="button" id="do-replace" value="replace" /> <textarea id="textarea"></textarea>
3. JAVASCRIPT
$(document).ready(function(){ $('#do-replace').on('click', function(e){ e.preventDefault(); // replace selected text by FOOBAR / 選択テキストを「FOOBAR」に置き換え $('#textarea').selection('replace', {text: 'FOOBAR'}); }) });
4. API
Tagged with:
jquery.selection
selection text
selection caret
selection
replace text
insert text
selected text
jquery pulgin
Related Articles