Question

How can I make a programmatical page selection visible to the user, as if it was selected by the user?

var range = document.createRange();
var startPar = [some node];
var endLi = [some other node];
range.setStart(startPar,13);
range.setEnd(endLi,17);

Thank you.

Was it helpful?

Solution

Use:

window.getSelection().addRange(range);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top