Dear All,

Please suppose that I have this line of code, and that my selection range goes from div element with id=1, starting at '2', to div element with id='2', ending at '8'.

<div id='1'>123</div>456<div id='2'>789</div>.

I'm using chrome, I would like to get the position of the cursor inside each element. I would get position 1 in div with id='1', and position 1 as well in div with id='2'.

Thank you so much for yout help,

Regards

I prefer to split textnodes into span elements with one character each. But if you want to take the challenge, you have to get the Range object and then obtain both start and end elements and offset.
A very complete reference of this can be read here. I hope it helps

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.