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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T01:22:42+00:00 2026-05-20T01:22:42+00:00

I would like to duplicate Wikipedia’s footnote highlighting from in-text citation click solely in

  • 0

I would like to duplicate Wikipedia’s footnote highlighting from in-text citation click solely in jQuery and CSS classes. I found a webpage that describes how to do so with CSS3 and then a JavaScript solution for IE. I would like however to do so solely with jQuery as the site I’m doing it on already has a bunch of jQuery elements.

I’ve come up with a list of the process.

  1. In-Text Citation Clicked
  2. Replace highlight class with standard footnote class on <p> tag of footnotes that are already highlighted.
  3. Add highlight to the appropriate footnote
  4. Use jQuery to scroll down the page to appropriate footnote.

I’ve come up with some jQuery so far but I’m extremely new to it relying heavy on tutorials and plugins to this point. Here is what I have with some plain English for the parts I haven’t figured out yet.

$('.inlineCite').click(function() {
   $('.footnoteHighlight').removeClass('footnoteHighlight').addClass('footnote');
   //add highlight to id of highlightScroll
   //scroll to footnote with matching id
});

If I had a method to pass a part of the selector into the function and turn it into a variable I believe I could pull it off. Most likely I’m sure one of you gurus will whip something up that puts anything I think I have done to shame. Any help will be greatly appreciated so thank you in advance.

Cheers.

  • 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-20T01:22:42+00:00Added an answer on May 20, 2026 at 1:22 am

    I copied Wikipedia’s superscript markup verbatim:

    <sup class="reference" id="cite_ref-1">
        <a href="#cite_note-1">
            <span>[</span>1<span>]</span>
        </a>
    </sup>
    

    And used the following jQuery:

    $(".reference > a").click(function() {
        var href = $(this).attr("href");
        var $el = $(href);
    
        $(".ref-highlight").removeClass("ref-highlight");
        $el.addClass("ref-highlight");
    });
    

    The key is grabbing the href off of the link that was clicked, and then using that to select the element and apply the highlight class.

    Also, you don’t need to scroll the page down programmatically, because the browser handles this for you automatically.

    Here’s a complete working example: http://jsfiddle.net/andrewwhitaker/dkWJm/2/


    Update: I noticed in your comment below you’d like to animate the scrolling, here’s how you would do that:

    $(".reference > a").click(function(event) {
        event.preventDefault();
        var href = $(this).attr("href");
        var $el = $(href);
    
        $(".ref-highlight").removeClass("ref-highlight");
        $el.addClass("ref-highlight");
        $("html, body").animate({"scrollTop": $el.offset().top}, 3000);
    });
    

    Notes:

    • We’re canceling the default action of the link in this case (using event.preventDefault()), which would be to jump to the element with the id matching the clicked link’s href.
    • Using animate to smoothly scroll the html element down to the appropriate position, which is determined using offset() on the target element.
    • The duration argument (I specified 3000) is what you would tweak to lengthen/shorten the duration of the scroll.

    Here’s an example of this: http://jsfiddle.net/andrewwhitaker/dkWJm/4/ (Updated to work in IE8/Chrome/FF 3)

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

Sidebar

Related Questions

Hi would like to duplicate an object from my core data db. Right now
I would like to remove the duplicate elements from a List. Some elements of
I would like to know an efficient method to remove duplicate items from a
Possible Duplicate: Draw Circle using css alone I would like to know if there
I would like to duplicate some roles from a production database to a test
I would like to remoe duplicate delegates from an event. So I have written
I would like to remove duplicate entries from a file. The file looks like
I'm working with ArrayBuffer objects, and I would like to duplicate them. While this
I would like to prevent duplicate content. I do not want to keep a
I would like to create an integer counter for duplicate entries on an intermediate

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.