Avatar of MJ
MJ
Flag for United States of America asked on

Extract Text From Modal using JavaScript?

How would I extract the text (Unfortunately, we don't yet operate in New Jersey. We are still growing!) from the below modal code, using JavaScript?

<div class="modal-overlay">
    <div class="modal-container" role="dialog" aria-labelledby="title-text" aria-describedby="dialog-text">
        <div class="modal-icons">             <div class="modal-header-exit"></div>             <div class="modal-header-icon"></div>         </div>         <div class="modal-header">             <h4 tabindex="-1" class="modal-header-title" id="title-text">State limitations apply</h4>         </div>         <div class="modal-content-container">             <p>Unfortunately, we don't yet operate in New Jersey. We are still growing!</p>             <div class="flexbox jc-center fd-row">                 <div class="button-container"><button type="button" class="button mt-4 button-primary button-full">Good to know</button></div>             </div>         </div>     </div> </div>

Open in new window

Thanks!

JavaScriptHTMLWeb Development

Avatar of undefined
Last Comment
Michel Plungjan

8/22/2022 - Mon
lenamtl

Hi,
What do you mean exaclty by extract?
What is the case?
MJ

ASKER
I need to grab the text "Unfortunately, we don't yet operate in New Jersey. We are still growing!" from the modal. The text will obviously change. I need a JS function that will return that string. Hope this makes sense? FYI... I have to use a Tag Manager so I have to inject my code. I can't modify the mark-up of the page. This is for analytic purposes.
ASKER CERTIFIED SOLUTION
Michel Plungjan

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Your help has saved me hundreds of hours of internet surfing.
fblack61