<style> | |
div::selection { background-color: green; } | |
</style> | |
<div id="target" style="font-size: 16px; height: 20px; line-height: 0px;"> | |
The House | |
</div> | |
<script> | |
// Select |The House|. | |
getSelection().setBaseAndExtent(target.firstChild, 2, target.firstChild, 12); | |
</script> |