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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T16:34:41+00:00 2026-06-11T16:34:41+00:00

I am new to JavaScript and jQuery so let me know if I’m way

  • 0

I am new to JavaScript and jQuery so let me know if I’m way off base.
I am using the cookie plugin from here: https://github.com/carhartl/jquery-cookie.

I have a page with dynamic links. They send the user to the same page they are already on with some GET information in the URL. I want to be able to highlight the previous link clicked.

My idea was to store the element that is clicked in a cookie and then add a class to that element.

Setting the cookie

$("td.column1").on({
    click: function () {
      $.cookie('productCookie', this); //How do I store 'this' into the cookie?
    }
});

Getting the cookie

var productValue = $.cookie('productCookie');
$(productValue).addClass("select singleselected");

Code without cookies

I know from experience that this line of code worked before I added the links, which is also before the page was being redrawn.

$(this).addClass("select singleselected");

I’ve tried looking into how the this keyword works but I’m afraid I’m not sure what selector the addClass method is getting or how to get the current element.

Solution Used

function getParameters(geturl, columnNumber) {
    var url = geturl,
        urlRegExp = new RegExp(url.replace(/\/$/, ''));

    $(columnNumber).each(function () {
        if (urlRegExp.test(this.href)) {
            $(this).addClass("singleselected select");
        }
    });
}
  • 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-11T16:34:42+00:00Added an answer on June 11, 2026 at 4:34 pm

    Check this thread out: jQuery add class .active on menu

    The basic idea is that you parse the current url and find the anchor tag that is active based on the url.

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

Sidebar

Related Questions

im new to jquery and javascript.. Here is the code, this is a sample,
I'm pretty new to jQuery, and I am converting a page from regular javascript
I'm new to javascript/jquery and I've done some poking around the web, but I
I'm very new to Javascript (and jQuery). My JSFiddle really shows the issue in
I'm really new to JavaScript and jQuery. My question is this. I have two
I'm new to JQuery/Javascript etc... based on the following article: How to make an
I'm pretty new to Javascript, Rails and JQuery all working together. I'm going through
I have just started learning Jquery and am new to writing javascript (I am
I am very new at jQuery ... I've used Javascript many times and am
New to whole this jQuery (and javascript altogether, heh) and so far it's been

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.