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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T18:12:14+00:00 2026-05-12T18:12:14+00:00

Beer <br> Vodka <br> rum <br> whiskey how can you select beer ? or

  • 0
Beer
<br>
Vodka
<br>
rum
<br>
whiskey

how can you select beer ? or rum ? in jquery ? they are not surrounded by any html tags….

  • 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-12T18:12:14+00:00Added an answer on May 12, 2026 at 6:12 pm

    If you mean that you want to select the text node directly, this is advised against using jQuery. To clarify, getting a wrapped set of text nodes is not a problem, but chaining commands onto a wrapped set of text nodes has unpredictable results or does not work with many of the commands since they expect the wrapped set to contain element nodes.

    You can do it by filtering the children of a parent to return only text nodes, i.e. nodeType === 3 but if your question is about performing some manipulation on the text, then get the parent element and manipulate the text contents. For example,

    $('#parentElement').html(); // html of parent element
    
    $('#parentElement').text(); // text content of parent element and any descendents
    
    $('#parentElement').contents(); // get all child nodes of parent element
    

    If you wanted to get the text nodes, the following is one way

    $('#parentElement').contents().filter(function() { return this.nodeType === 3 });
    

    Or you may want to look at Karl Swedberg’s Text Children plugin, which provides various different options too.

    EDIT:

    In response to your comment, one way to work with the text nodes in a wrapped set is to convert the jQuery object to an array, then work with the array. For example,

    // get an array of the immediate childe text nodes
    var textArray = $('#parentElement')
                        .contents()
                        .filter(function() { return this.nodeType === 3 })
                        .get();
    
    // alerts the text content of each text node
    $.each(textArray, function() {
        alert(this.textContent);
    });
    
    // returns an array of the text content of the text nodes
    // N.B. Remember the differences in how  different 
    // browsers treat whitespace in the DOM
    textArray = $.map(textArray, function(e) {
        var text = $.trim(e.textContent.replace(/\n/g, ""));
        return (text)? text : null;
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Free as in beer. I can live without the source code. About 10 years
so Here's my query: SELECT b1.beer as beer1, b2.beer as beer2 , b1. price
My beer model has a brewery object but I can't access the brewery's properties
I've been looking for a free (as in free beer) library that can parse
I have a string like The beer party 2011/2012 in PHP. I still cannot
I'm working on my project: [Beer Pong Management System][1], a Windows Forms application. I
Given a simple Parsekit grammar. @start = sentence+; sentence = 'beer' container; container =
When writing in java the following: Element fieldEl = targetDocument.createElement(field); fieldEl.setAttribute(Wine,Marlo); fieldEl.setAttribute(Beer,Corona); The order
We were having a beer talk and have something to clear out. Is the
Lets say I have a wine and beer model/controller along with a wine_review and

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.