Alternative Approach to find the Middle

The previous approach didn't work, so we'll try to use a different approach to find the middle of the cursor.

The range property

Our previous attempt of wrapping the text we want in a span and getting the position of the span didn’t work. Time to Google for another lead. Searching for “get position of text”, I find a range property which I saw in the getSelection API but hadn’t paid attention to.

Get hands-on with 1200+ tech skills courses.