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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:31:58+00:00 2026-05-26T05:31:58+00:00

I have a very simple Javascript (jQuery) code, which just add a class name

  • 0

I have a very simple Javascript (jQuery) code, which just add a class name to the HTML link <a> element when the link is clicked, then use CSS to change the link background to red.

You will see in my code, I defined the background color for HTML link visited, hover, active . The Javascript (jQuery) code is just to addClass() to the <a> link tag to change the background color to red by using CSS if the link has been clicked.

My code is here on jsfiddle, Why it does not work?

—————New problem————————

Seems the thing get different if I put the link inside a table (as a content of <td>), like this code shows, why now the background does not change to red???? (But the font size did change, strange, seems partly highlighted)

  • 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-26T05:31:58+00:00Added an answer on May 26, 2026 at 5:31 am

    First, jQuery objects have .addClass available. So not this.addClass, but $(this).addClass. $(this) creates a jQuery object from an element.

    Secondly, a .highlight means: any descendants of <a> elements with a class of highlight. You want <a> elements which have that class themselves, so use a.highlight (without the space).

    http://jsfiddle.net/YJH9g/10/

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

Sidebar

Related Questions

I have a very simple javascript class that does an ajax call to a
I have the following very simple Javascript-compatible regular expression: <script type=text/javascript id=(.+) src=([^]+)> I
i have very simple problem. I need to create model, that represent element of
I have a very simple problem which requires a very quick and simple solution
I have a very simple WPF application in which I am using data binding
I have the following code in Javascript: jQuery(document).ready(function(){ var actions = new Object(); var
I have the following Javascript/jQuery function: function addEventHandler(){ $(div).mouseenter(function() { $(this).html(Over); }).mouseleave(function() { $(this).html(Out);
I'm new in Jquery. I have a problem in my code, i'm very confused
I have spent the last two days looking for a simple javascript or jquery
I have a very basic function which I am using jQuery to slide some

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.