I need to select text between any two given HTML nodes (in the order thats visible to user).

As an example in following screenshot(<https://aws.amazon.com/connect/faqs/>), I want to select answer between two questions.

> 
> Yes. We encourage you to go to the Amazon Connect console and set up
> an Amazon Connect contact center now.
> 
> 
> 

[![enter image description here](https://i.stack.imgur.com/Z1pxE.jpg)](https://i.stack.imgur.com/Z1pxE.jpg)

**Edit:**

In another works I am looking for completion of this function

```
// firstElement and secondElement don't need to be related.
// They dont be part of same subtree

   function getBetweenElements(firstElement, secondElement) {

       ...

      return result;
    }

```