What am I doing wrong? Everything executes without an error but it never selects the text.

Code:
var div = document.getElementById( "myDiv" );
		
var range = document.createRange();
		
//Get the span element
var startNode = document.getElementsByClassName( "spanElement" )[ 0 ].firstChild;
		
//Set the start
range.setStart( startNode, 4 );
		
//Set the end
range.setEnd( div.firstChild, 7 );
		
window.getSelection().addRange( range );