2 Replies Latest reply on Sep 28, 2016 7:34 AM by Vamitul

    Get parent (paragraph) of text

    leenh61786917

      Hi all,

       

      I ran into a problem and can't seem to find the solution myself. It is like this:

       

      Let's say you have a story with two paragraphs. One paragraph has 'hello' in it and the other paragraph has 'world' in it as text.

      You can select for example 'hello', then click a button and then after you click the button it has to change to for example 'greetings'.

      So then you have one paragraph with 'greetings' and the other still with 'world'.

       

      Now I have the following code which I need to change:

      var selectedContent = app.selection[0].contents; // this has the selection, 'hello'.

      var contentToChange = app.selection[0].parent; // this has the story.

       

      I want contentToChange to be the paragraph in which the text resides.

      .parent gets the story, so everything disappears and becomes just 'greetings'.

      Tried many things, but can't find the solution (what I should use instead of 'parent' to get the paragraph).

       

      Can someone help please, thanks in advance,

       

      Greetings