multiple-text-selection-ref.html (738B)
1 <!-- 2 Any copyright is dedicated to the Public Domain. 3 http://creativecommons.org/publicdomain/zero/1.0/ 4 --> 5 <!DOCTYPE html> 6 <style> 7 html, body { margin: 0 } 8 svg, div { display: inline-block; width: 700px; height: 200px } 9 div { font: 16px sans-serif } 10 #a { margin-left: -700px; vertical-align: 100px } 11 #b { margin-left: -700px; vertical-align: 50px } 12 span { margin-left: 100px } 13 </style> 14 <body> 15 <svg></svg><div id=a><span>hello</span></div><div id=b><span>there</span></div> 16 <script> 17 var span = document.getElementsByTagName("span"); 18 var range = document.createRange(); 19 range.setStart(span[0].firstChild, 1); 20 range.setEnd(span[1].firstChild, 4); 21 window.getSelection().addRange(range); 22 </script> 23 </body>