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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T14:12:32+00:00 2026-06-07T14:12:32+00:00

If I am dynamically generating HTML similar to this? <li class=ui-state-default ui-corner-top id=tab_pg_4> <a

  • 0

If I am dynamically generating HTML similar to this?

<li class="ui-state-default ui-corner-top" id="tab_pg_4">
    <a href="#ui-tabs-8"><span>Group5</span></a>
</li>

<li class="ui-state-default ui-corner-top" id="tab_pg_5">
    <a href="#ui-tabs-10"><span>Group4</span></a>
</li>

<li class="ui-state-default ui-corner-top" id="tab_pg_6">
    <a href="#ui-tabs-19"><span>Group8</span></a>
</li>

and I have a javascript variable which contains the string Group4

How do I console.log or alert tab_pg_5?

  • 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-06-07T14:12:34+00:00Added an answer on June 7, 2026 at 2:12 pm

    Use the jquery function .closest() to find the closest matching ancestor.

    var myVar = 'Group4';
    console.log($('a[href^="#ui-tabs-"] span:contains("' + myVar + '")').closest('li').attr('id'));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am dynamically generating a function and assigning it to a class. This is
I'm generating HTML dynamically using Delphi strings (Delphi XE). What is the correct way
i am generating html control dynamically and now i want to wrap the html
I'm generating buttons dynamically that I want it to call a method like this:
This code should not generate any HTML button dynamically. Coz there is no div
I am generating a html table dynamically through C# code. I want to be
I am dynamically generating a div and want to change its content via html()/text(),
Thanks for reading this. I am dynamically generating some data which includes a select
This code / markup... <ul id="tag-directory" class="clearfix"> <li py:for="tag in tags"><a href="${h.url_for(controller='/media', action='index', tag=tag.slug)}">${tag.name}</a>
I am dynamically generating HTML and feeding it into a UIWebView. I have a

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.