Save and restore selection

This example shows how to save and restore selection with API.

Select some text and click to buttons.


Code

<!-- api buttons -->
<button onclick="$R('#content', 'selection.save');">Save</button>
<button onclick="$R('#content', 'selection.restore');">Restore</button>

<!-- element -->
<textarea id="content"></textarea>

<!-- call -->
<script>
$R('#content');
</script>