blob: b74047098fa4cc165f89ed1428a9f0cc0f78c1fd [file] [edit]
<style>
#selection_start {
display: grid;
}
#selection_start::selection {
background-color: transparent;
}
</style>
before selection
<div id=selection_start>start</div>
<div id=selection_end>end</div>
after selection
<script>
const selection = window.getSelection();
const range = document.createRange();
range.setStart(document.getElementById("selection_start"), 0);
range.setEnd(document.getElementById("selection_end"), 1);
selection.addRange(range);
</script>