addRange
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since March 2017.
Resumen
Añade un objeto de rango a la selección.
Sintaxis
sel.addRange(range)
Parámetros
Ejemplos
/* Seleccionar todos los elementos en NEGRITA en un documento HTML */ var strongs = document.getElementsByTagName("strong"); var s = window.getSelection(); if(s.rangeCount > 0) s.removeAllRanges(); for(var i = 0; i < strongs.length; i++) { var range = document.createRange(); range.selectNode(strongs[i]); s.addRange(range); }