Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 294639
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T06:23:07+00:00 2026-05-12T06:23:07+00:00

In JavaScript/JQuery I want to get all the text that is seen between some

  • 0

In JavaScript/JQuery I want to get all the text that is seen between some other text. For example, if the HTML document had:

<b class="blah">Blah: Some Text 1</b>
<div id="foo"><b class="blah">Blah: Some Text 2</b>

I’d like to get an array that has ‘Some Text 1’ and ‘Some Text 2’ since they are both in between ‘<b class="blah">Blah:‘ followed by a ‘</b>‘

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T06:23:07+00:00Added an answer on May 12, 2026 at 6:23 am

    Since you mention jQuery, just select all the right nodes and check their text. You can put a regex in here if you want, but it’s not needed.

    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html lang="en">
    <head>
    <title>test</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <script type="text/javascript" src="http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js"></script>
    <script type="text/javascript">
    $( function(){
        var texts = [];
        $('b.blah').each( function()
        {
          var txt = $(this).text();
          if ( 0 == txt.indexOf( 'Blah:' ) )
          {
              texts.push( txt.substr( 6 ) );
          }
        } );
        alert( texts );
    });
    </script>
    
    </head>
    <body>
      <b class="blah">Blah: Some Text 1</b>
      <div id="foo"><b class="blah">Blah: Some Text 2</b>
      <div id="foo"><b class="blah">Some Text 3</b>
    </body>
    </html>
    

    Or with a string of HTML

    $( function(){
      var htmlChunk = '<b class="blah">Blah: Some Text 1</b>\n'
        + '<div id="foo"><b class="blah">Blah: Some Text 2</b></div>\n'
        + '<div id="foo2"><b class="blah">Some Text 3</b></div>';
    
        var texts = [];
        $('b.blah', '<div>' + htmlChunk + '</div>').each( function()
        {
          var txt = $(this).text();
          if ( 0 == txt.indexOf( 'Blah:' ) )
          {
              texts.push( txt.substr( 6 ) );
          }
        } );
        alert( texts );
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some jQuery/JavaScript code that I want to run only when there is
I know that in jQuery you can use something like $(.cssClass) to get all
I want to handle F1-F12 keys using JavaScript and jQuery. I am not sure
I already started this in javascript so I don't want to use jquery but
The below HTML/CSS/Javascript (jQuery) code displays the #makes select box. Selecting an option displays
How have you guys handled working with jQuery includes <script type=text/javascript src=jquery.js></script> in Asp.Net
I'm struggling to get what i think should be a simple bit of jquery/javascript
I'm studying jquery and html5 canvas. All I want to do is a simple
New to javascript/jquery and having a hard time with using this or $(this) to
I've rewritten my family web site using JavaScript (JQuery) making Ajax calls to PHP

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.