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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:39:09+00:00 2026-05-27T16:39:09+00:00

I have a html code like <div> <span>TV</span> </div> I want to find this

  • 0

I have a html code like

<div>
   <span>TV</span>
</div>

I want to find this span through documentObject having text ‘TV’, like getElementById etc … something like getElementByText. I know that it’s possible through XPath/JQuery/Regex.

But I need it to get through DOM object model only. As only DOM model is available in my context.
I see couple of answers:

  • Finding an html element ID based on a text displayed
  • jquery – find element that only has text and not any other html tag
  • how to find element after some text with javascript?

But these are not helpful to me, as I need to get it through DOM model only.

  • 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-27T16:39:10+00:00Added an answer on May 27, 2026 at 4:39 pm

    Assuming the document is well-formed enough to parse into a proper DOM object tree, you can iterate through the entire structure without using an external library. Depending on the structure, you may have to examine every node to find all matches, and this may be slow. If you have access to IDs of any sort, you may be able to reduce search scope and improve performance.

    The key property you will need is the childNodes collection on every DOM node. Starting with the BODY (or some other container), you can recurse through all the child nodes.

    This site is pretty basic but shows dependency-free methods for accessing DOM elements. See the section called “Tools to Navigate to a Certain Element”.

    I noticed that you mentioned regular expressions as a means to find elements. Regexes are poor for parsing entire documents, but they can be very useful in evaluating the textual content of a single node (e.g. partial matches, pattern matches, case insensitivity, etc.) Regular expressions are part of the JavaScript language itself and have been so for well over a decade.

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

Sidebar

Related Questions

I have a HTML code like this: <div class=links nopreview><span><a class=csiAction href=/WebAccess/home.html#URL=centric://REFLECTION/INSTANCE/_CS_Data/null>Home</a></span>&nbsp;•&nbsp;<span><span><a class=csiAction href=/WebAccess/home.html#URL=centric://SITEADMIN/_CS_Site>Setup</a></span>&nbsp;•&nbsp;</span><span><a
I have HTML code like this : <div> <a>Link A1</a> <a>Link A2</a> <a>Link A3</a>
I have html code that looks roughly like this: <div id=id1> <div id=id2> <p>some
Say I have jquery code like this: html += '<div class=index>' + item.index +
For example I have this HTML code: <div id=canvas> <div id=root> <div id=content> <span>
I have a HTML code like this: <pre><div class=post style=border-width:1px;border-style:solid> <div class=userpic style=width:70px;float:left> <img
i have html code that looks like the following: String html = <html><head><style type=\text/css\></style></head><body><div
I have a template like this: <script id=notesTemplate type=text/html> <li class=Note> <div class=NoteDate data-bind=style:
I have html code like this <tr class=odd> <td><b>Reason for Termination:</b></td> <td>this has bunch
I have the following html code: <h3 id=headerid><span onclick=expandCollapse('headerid')>&uArr;</span>Header title</h3> I would like to

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.