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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T05:47:14+00:00 2026-06-04T05:47:14+00:00

I am initially styling links(also different states) using css and then i am changing

  • 0

I am initially styling links(also different states) using css and then i am changing css properties for a tag using jquery css() function. The problem is- the css() function seems to effect not only a but also all it states.
That mean writing ‘a’ corresponds to all states of ‘a’. So we need to write something kind of a:link and change only ‘a:link’ not ‘a’.

How to write this using jquery.

Code what I am doing:
CSS:

#topics_nav a {
    color:#000; 
}
#topics_nav a:visited{
    color:#c00;
}
#topics_nav a:hover,a:active,a:focus{
    color:#FFF;
}

jquery:

$("document").ready(function(e) {
    $('#topics_nav a').css('color','#300');
});

This jQuery changes color of all states to #300.

I don’t want to change only the link state and don’t want to modify any other state. The following solution give a method to only affect hover(or any other) state but is there any other method instead of adding/deleting classes.

There is a solution to define some desired classes(classes like class1:hover) and instead of changing css we can change class.
But what about :link?

  • 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-04T05:47:16+00:00Added an answer on June 4, 2026 at 5:47 am
    #topics_nav a {
        color:#000; 
    }
    #topics_nav a:visited{
        color:#c00;
    }
    #topics_nav a:hover,a:active,a:focus{
        color:#FFF;
    }
    .myclass:hover {
        color: #300;
    }
    
    
    $("document").ready(function() {
        $('#topics_nav a').addClass('myclass');
    });
    

    I think this is a better way to do it. Let CSS style the elements like this.

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

Sidebar

Related Questions

Initially I used the meta tag: <meta name=viewport content=width=device-width, initial-scale=1.0/> On using this tag,
Initially i added full source code for viewer. but it has some format problem
I am having a bit of trouble with styling by active links, and I
I'm working on a jQuery theme which includes styling for as many form elements
Initially my code was build/compiled using open-jdk7. But due to some constraints I now
Initially I created a bitmap from an external URL by using a bitmapFactory .
Initially I sent the converted object using .to_json which gives me a string I
Initially i had x64 bit java sdk and x64 bit STS installed. But then
Initially, I thought I could use :first-letter in CSS, legacy browser support aside, but
Initially there are only th in in the table.My question is that from jquery

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.