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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T16:25:43+00:00 2026-05-22T16:25:43+00:00

Hi i recently asked a question regarding targeting dynamically produced links and someone kindly

  • 0

Hi i recently asked a question regarding targeting dynamically produced links and someone kindly provided me a working answer however, having looked into it in more detail, the functionality i need is slightly different.

The following code toggles the highlighted class for a paragraph that corresponds to a link that’s being produced by a separate function. this is based on 3 mouse events:

$("#hi-4").live("mouseover mouseleave click", function(){
    $("p#p-4").toggleClass("highlighted");
});

This works great, however i would like the highlighted class to stay if the relevant link is clicked(until another link is clicked) Currently it toggles for each event listed and doesn’t stay highlighted if clicked. I have tried creating separate functions for each event and have tried using .addClass, .removeClass ` in different combinations for each event but i cant get it to stay highlighted only when clicked. many thanks

EDIT:

Heres a jsfiddle link http://jsfiddle.net/RVYnb/6/ to an example,thanks

  • 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-22T16:25:43+00:00Added an answer on May 22, 2026 at 4:25 pm

    You mean you want the highlighting to stay on till the user clicks something else?

    Behavior like this? : http://jsfiddle.net/QLEHY/1/

    <a href='#'>Para 1</a>
    <a href='#'>Para 2</a>
    <a href='#'>Para 3</a>
    
    <p>Some text. Some text. Some text. Some text. Some text. </p>
    <p>Some text. Some text. Some text. Some text. Some text. </p>
    <p>Some text. Some text. Some text. Some text. Some text. </p>
    
    
    $('a').click(function(){
       $('p.active').removeClass('active');
       $('p') .eq($(this).index()).addClass('active');
    });
    

    In the context of your code, simply removing the class before applying it should be fine.

    $("#hi-4").live("mouseover mouseleave click", function(){
        $('p.highlighted').remove(); //remove all the highlighted classes. 
        $("p#p-4").toggleClass("highlighted");
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I recently asked a question here, and someone provided this answer: private void button1_Click(object
I recently asked this question regarding pulling beans out of an applicationContext. The answer
I recently asked a question about what I called method calls. The answer referred
I recently asked another question pertaining to avoid having to use boilerplate exceptions when
I recently asked a question about some problems I was having getting MIT Kerberos
I've recently asked a question regarding IE8 issue. After some time the problem was
I've recently asked a question regarding best ways of separating business logic from data
In a recent question asked recently my simple minded answer highlighted many of my
Please see here for a question I recently asked. The only answer you should
In another question that i asked recently i got a really good answer and

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.