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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T16:58:22+00:00 2026-05-21T16:58:22+00:00

I have this: <a href=# id=article-2341234 class=article-link>click to see article</a> <div id=article-body-2341234 style=display:none;> …

  • 0

I have this:

<a href="#" id="article-2341234" class="article-link">click to see article</a>
<div id="article-body-2341234" style="display:none;"> ...
...
...
</div>

Now I want to do this:

  1. prevent default
  2. get articleid ‘2341234’ from the id of the link just clicked
  3. hide the link and display the article below it

I also want to capture the recently clicked link in a variable as I will refer to it many times in the click event and I want to be effecient.

I have this so far:

$(".article-link").bind("click", function(e) {

e.preventDefault();
var articleId = ?????;

$("#article-link-" + articleId).hide();
$("#article-body-" + articleId).show();


});

I need a generic function that will get the ‘articleid’ from the ID of the element, how can I do this?

How can I store the recently clicked link in a variable so I can refer to it again. Is it:

$(this) ?

  • 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-21T16:58:23+00:00Added an answer on May 21, 2026 at 4:58 pm

    Easiest way would be to simply do a replace() on this.id to grab your article id.

    $(".article-link").bind("click", function(e) {
      e.preventDefault();
      var articleId = this.id.replace("article-link-", "");
      $(this).hide();
      $("#article-body-" + articleId).show();
    });
    

    Side note, you can just do $(this).hide() instead of querying the dom again as this will refer to the dom element clicked.

    Code example on jsfiddle

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

Sidebar

Related Questions

i have this code: $('.access a').toggle(function() { $('link').attr('href', 'styles/accessstyles.css'); $('body').css('font-size', '16px'); }, function() {
I have the following jquery script: $(function(){ $('#top-menu').on('click', 'a.change-menu', function(e){ e.preventDefault() $(#menu-change-div).load($(this).attr(href)); }); });
I have this html. <a class=link href=www.website.com?id=233253>test1</a> <a class=link href=www.website.com?id=456456>test2</a> How can I hide
I have this href link with text either attivo or non attivo User can
I have this function: <script type='text/javascript'> $('#clicktogohome').live('click', function(){ history.pushState({}, '', this.href); popstate(this.href); return false;
Let's say I have an array of objects [{href: 'some_uri', 'class': 'this-css-class'}, {href: 'another_uri',
<div id=contentChildren class=frame> <div id=icon_com.tms.cms.article.Article_fc7be680-c0a8c88d-1be20c00-e3a2814e> <a class=contentItem Article href=http://localhost:9080/ekms/contentexplorer /explorer.jsp?cn=contentExplorer.panel&et=openMenu&contentId=com.tms.cms.article.Article_fda4d360-c0a8c88d-ae8af400-e4f04255> </div> </div> I have
I have a HTML with the following format <article class="cik" id="100"> <a class="ci" href="/abc/1001/STUFF">
I have this: $(a.money).colorbox({href:$(a.money).attr(href)+ div#content}); Which opens an overlay but only of the content
I have html div class formated accordingly.... <div class=latest-media-images> <div class=hdr-article>LATEST IMAGES</div> <a class=lnk-thumb

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.