Detect Phrase on a Web-page?

I'm trying to figure out how I can scrap/detect if the phrase "We regret we cannot open the account you requested." is on the page using CSS Selector and/or Javascript (jQuery is ok if that is the only option but want to avoid it if possible?). Below is an excerpt from the mark-up.
<!-- current page: offers --> 
        <div class="main">
     <h3>Eligibility Results</h3><p>Thank you for your online application for an account at Bank of the West.  We regret we cannot open the account you requested.<br/>
If you would like to discuss this application with Bank of the West, please contact us at:</p>

Open in new window


Thanks!
894359Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Steve BinkCommented:
This isn't possible with CSS.

With Javascript, you can use document.getElementById() to target the parent container.  Then get that element's innerText property to search for your text:
<script>
  var my_element = document.getElementById('main');
  if (my_element.innerText.search('We regret we cannot open the account you requested') > -1) {
    // text is found
  }
  else {
    // text is not found
  }
</script>

Open in new window


https://developer.mozilla.org/en-US/docs/Web/API/Node/innerText
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/search
0
894359Author Commented:
Just realized main is a class and NOT an ID! :0)
0
Steve BinkCommented:
If you are targeting a class, try using getElementsByClassName instead.  Note that you'll be receiving an array back, not a single element, so you'll need to iterate it to do your work.  The doc page has some relevant examples for you.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
894359Author Commented:
try{
    var appDeclined = 0;
    var myCollection = document.getElementsByClassName('main');
    i = myCollection.length;

    while(i--) {
        if (myCollection[i].innerText.search('We regret we cannot open the account you requested') > -1) {
            appDeclined = 1;
        }
    }
  
    
  
} catch(e) {} 

Open in new window

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Development

From novice to tech pro — start learning today.