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

  • Home
  • SEARCH
  • 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 6820807
In Process

The Archive Base Latest Questions

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

I have an anchor like: <a href=# onclick=showInfo(); class=nostyle ></a> I don’t have id

  • 0

I have an anchor like:

<a href="#" onclick="showInfo();" class="nostyle" ></a>

I don’t have id or class name because I generated it dynamically in xslt.

When I click on it, it shows a previously hidden div that contains an <a id='close'> tag. The idea is to change the background color of the first anchor when I click on the close button, but I don’t know how I can set that up.

How can I get the anchor which was clicked and therefore change it?

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

    Check out this solution for a page that has multiple hidden divs, and each div has a show/hide link

    http://jsfiddle.net/qfQhq/

    This works for 1 div and 1 hide and 1 show link

    An easy way to do this, is when you click the link to show the hidden div, save a reference to the link by stashing the $(this) pointer into a global variable and then displaying the hidden div. If the link which opens the hidden div has a background-color (or class to do so) you may want to remove it at this point. (if the color only shows up when you close the div, you may want it to disappear when you open the div too?)
    Once you click the close button, you can simply reference the same global variable as if it is a DOM element, and change it’s background color (or add a class to it, that does it for you).

    $(document).ready(function(){
    

    1) Create Global Variable

    var showInfoLink = "null";
    

    2) Store $(this) (DOM Element that triggered showInfo();)

    function showInfo() {
        showInfoLink = $(this);
        showInfoLink.removeClass("highlighted"); //if you closed the div & opened again
        $("#hidden_div_selector").css("display", "block"); //show hidden div
    }
    

    3) Change background-color or the link

    $("#hidden_div_close_button_selector").click(function(){
        if (showInfoLink != "null")
        {
            showInfoLink.addClass("highlighted"); //color the background of the link
            $(this).css("display", "none"); //hide the hidden div
            showInfoLink = "null";
        }
    }
    

    4) CSS For ‘highlighted’ class (changed bg color)

    .highlighted {
        background-color: #de9f3c; //random color
    }
    

    make sure this is all in $(document).ready()

    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Consider I have an anchor which looks like this <div class=res> <a href=~/Resumes/Resumes1271354404687.docx> ~/Resumes/Resumes1271354404687.docx
I have a bunch of URLs structured like so <h4 class=classname><a href=http://some-website.com onclick=someVaryingJS(); title=Some
I have an Anchor Tag like this <a href=javascript:anchorScr() id=anch1 class =af-link/> It is
I have a anchor tag like this <a href= class=search gl> <img src=_gfx/cmn/goButton.png class=searchbutton
I have an anchor element that looks like this <a href=url><img src=imgurl/>Text</a> I would
Say I have an anchor on a webpage like so: <a name=comegetit></a> Is there
I have an image tag enclosed in an anchor element like this: <a href='$image'><img
I'm using CodeIgniter (because it's awesome) and I have something like: <?php echo anchor(/,
I have a set of dynamically generated anchor tags in a for loop as
I have a link with 'remove' anchor text with href something like below: ./index.php?del_id=5

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.