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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:54:48+00:00 2026-05-26T21:54:48+00:00

I have a bunch of these on a page: <div class=item id=555> <div class=wrapper>

  • 0

I have a bunch of these on a page:

<div class="item" id="555">
  <div class="wrapper>
    <p>Make Link One</p>
  </div>
  <p class="action">Make Link Two</p>
</div>

How can I dynamically make the 2 texts links based on the id 555? ie. They both should be links to http://555

There is a unique business requirement which is the reason they’re not just normal hrefs to begin with.

  • 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-26T21:54:49+00:00Added an answer on May 26, 2026 at 9:54 pm

    You can just bind a click event handler to the containing div that uses it’s own ID to redirect the user:

    $('.item').on('click', function () {
        window.location = 'http://' + this.id;
    });
    

    If you have other content inside the container element that should not trigger the redirect then you can bind to the <p> elements inside the container:

    $('.item').on('click', 'p', function () {
        window.location = 'http://' + $(this).parents('.item:first')[0].id;
    });
    

    BTW, IDs should not start with numbers. Here’s a link to the correct syntax for IDs: What are valid values for the id attribute in HTML?

    Note that .on() is new in jQuery 1.7. In the first example replaces the depreciated .bind() and in the second example it replaces the depreciated .delegate().

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

Sidebar

Related Questions

So I have two div elements on my page, one directly on top of
week DKK id=radio2 value=75 /> I have bunch of these div entry generated by
I have a bunch of Div's on the page <div id=MainDiv><div>sometext</div> <div>sometext</div> <div>Page 1</div>
I have a bunch of these little bits of HTML code repeated over and
I have a bunch of dynamically created *.BAT files. These BAT files are used
If I have a bunch of objects, and within these objects is the string
I have an application creating a bunch of divs through a loop. Each div
I have a dynamically appearing div on a page. I would like to be
I display a bunch of posts from users on a page. I have the
I have a div with a unique ID. Under that div are a bunch

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.