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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:59:51+00:00 2026-05-26T10:59:51+00:00

So basically I have a few links, when you click one, it should add

  • 0

So basically I have a few links, when you click one, it should add the highlighted class. I also have a button that when clicked should hide the link with the highlighted class.

This seems trivial and should be very simple, but I can’t understand why my code does not work. Another thing, is for some reason, the links still go through once clicked in the fiddle. Not sure if it’s something with jsfiddle and how it handles external links?

Here is my fiddle: http://jsfiddle.net/ZPGe7/1/

  • 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-26T10:59:52+00:00Added an answer on May 26, 2026 at 10:59 am

    You should not cache the jQuery object, because it doesn’t update when the elements receive different class names. Also, use event.preventDefault() to prevent the link from being followed. Directly use $('.links a.highlight') in your code.

    Fiddle: http://jsfiddle.net/ZPGe7/2/

    $(function() {
        $('.links a').live('click',function(ev){
                $('.links a.highlight').removeClass('highlight');
                $(this).addClass('highlight');
                ev.preventDefault(); //Prevent link from being followed
        });
        $('#submit').live('click',function(){
            $('.links a.highlight').hide();
        });
    });        
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have cobbled together a class that checks links. It works but it is
I have a table with records that has delete links. Basically I followed the
Basically on GunChester my project I have an few pixel wide gap between #login_top
I have a loop which basically calls this every few seconds (after the timeout):
I basically have 7 select statements that I need to have the results output
I have one textbox basically the user is going to enter in a 9
currently we have a TFS Server that has a few files with many branches,
I have a few tables that I need to link together to get a
Basically put, I have an action that saves a form to a database, then
I have a page when user can add 0 to N TinyMCE editors that

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.