1

I am attempting to determine whether the cursor is at the beginning of a container (where contenteditable is true), ignoring whitespace or HTML elements that comes first. For instance:

<div class="layout-container" contenteditable="true">
    <div class="slice-content">
        <p>       Hello World</p>
    </div>
</div>

<div class="layout-container" contenteditable="true">
    <div class="slice-content">
        <p>Hello World</p>
    </div>
</div>

<div class="layout-container" contenteditable="true">
    <div class="slice-content">
        <p>  <span style="font-weight: normal;">Hello</span> World</p>
    </div>
</div>

Regardless of which ones of these is used to create the following: enter image description here

I would still want it to return 0.

Currently, I am using the following:

window.getSelection().getRangeAt(0).startOffset;
William
  • 3,335
  • 9
  • 42
  • 74
  • This may help: http://stackoverflow.com/questions/16105482/get-current-cursor-position-in-a-textbox – Matt Jun 20 '16 at 16:06

0 Answers0