<!doctype html> | |
<p><span style="font-size: 500%; color: red;"> [!(5)#]</span>9abcdefghi</p> | |
<script> | |
const selection = window.getSelection(); | |
const sample = document.querySelector('p'); | |
// Select "abc" | |
selection.collapse(sample.lastChild, 1); | |
selection.extend(sample.lastChild, 4); | |
</script> |