Index, by my definition is, the numbers indicate the position order of elements within a container.
Code:
<!DOCTYPE html>
<html>
<head>
<style>
</style>
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
</head>
<body>
<div></div>
<div></div>
<div id="blinking"></div>
<div></div>
<div></div>
<div></div>
<script>
alert($("#blinking").index());
</script>
</body>
</html>
In this code, the id blinking represents the node where the caret is. the id blinking has index of 2 inside body container.
What I am trying to archive is, when I open a working document, I want the caret to be exact position when I left off.
To do so I need to store the words offset and the node which contain the caret, but the node returned by selection.anchorNode is an object, we can't store object in database. Therefore, we need to get the index value of the node. so that we can do something like this
Code:
sel.collapse(content.childsNode[4], 23);// put the caret at fifth node, offset 23 characters
Back to my question, how do we capture index of the node where the caret is ?
Bookmarks