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 901901
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T15:37:59+00:00 2026-05-15T15:37:59+00:00

i want to grab the text between two tags, which is in main div,

  • 0

i want to grab the text between two tags, which is in main div, following is the example…

<div class="main_result">

some text....
<div>other divs</div>
<p>some other html</p>
<div class="bread_crump"></div>

text i want to grab

<b>selected category</b>
some other text and div...

</div>

obviously following example dont work, but its an idea..

var count = $('.main_result', data)
                                .find('.bread_crump')
                                .after('<span class="count_total" style="color:red">')
                                .parents('.main_result')
                                .find('.bread_crump ~ b')
                                .before('</span>')
                                .parents('.main_result').html();
  • 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-15T15:38:00+00:00Added an answer on May 15, 2026 at 3:38 pm
    var txt = $('.main_result')
              .contents() // get it's contents
              .filter(function() { //filter the result for textnodes that aren't empty (helps ie's parsing of textnodes)
                 if( this.nodeType == 3 && $.trim(this.data) != "") { //get only text nodes and filter out whitespace elements
                     return true;
                 }
                 return false;
              }).get(1).data; // get 1 because it's your 2nd non-whitespace text node
    
    var txt = $.trim(txt); // trim out all the new lines 'n stuff
    

    Better, though, to wrap these elements in something you can a) find easily and b) rely on (the number of text-nodes can get iffy)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to grab text inside a div element like this : <div class='someclass'>
I have the following regular expression: (?:<(?<tag>\w*)>(?<text>.*)</\k<tag>>) I want it t grab the text
I'm parsing HTML page with XPath and want to grab whole text of some
i want to grab text from HTML do some process and change to it
I have a html element: <div id=myElement class=someClass onclick=setText(this.innerHtml) runat=server>text</div> I want to be
I have an RSS feed which has an image and some text. I want
I have an id: div id =untitled-region-5 I want to grab that id and
Want to grab list of players from http://www.atpworldtour.com/Rankings/Singles.aspx There is a table with class
I have a table of data that I want to grab text from, stick
Sample text = legacycard.ashx?save=false&iNo=3&No=555 Sample pattern = ^legacycard.ashx(.*)No=(\d+) Want to grab group #2 value

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.