0

I have this code so far:

 var targetDoc = DocumentApp.getActiveDocument();
 var cursor = targetDoc.getCursor().getElement();
 var cursorParent  = cursor.getParent();
 var cursorPoint = cursorParent.getParent().getChildIndex(cursorParent);

But this brings back the child of the cursors parent's parent which is always 0. I cannot find a way to get the childIndex of the cursor's own parent.

Does anyone know how to do this?

Kind Regards.

1 Answer 1

2

I was totally over thinking it. I separated out my code from the main function and found this will bring back the index number of the cursor's parent:

var targetDoc = DocumentApp.getActiveDocument();
var cursor = targetDoc.getCursor().getElement();
var cursorParent  = cursor.getParent().getChildIndex(cursor);
Logger.log(cursorParent);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.