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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T06:45:56+00:00 2026-06-07T06:45:56+00:00

i have five divs <div id=box1>content 1</div> <div id=box2>content 2</div> <div id=box3>content 3</div> <div

  • 0

i have five divs

<div  id="box1">content 1</div>
<div  id="box2">content 2</div>
<div  id="box3">content 3</div>
<div  id="box4">content 4</div>
<div  id="box5">content 5</div>

each that is highlight accordingly when i click on a certain link

<a class="light" id="1">link 1</a>
<a class="light" id="2">link 2</a>
<a class="light" id="3">link 3</a>
<a class="light" id="4">link 4</a>
<a class="light" id="5">link 5</a>

this is my jquery

$(".light").live("click", function(){
var id = $(this).attr('id');
$("box"+id).css({'background':'red'});

});

stuck at this point, i would like to dehighlight the previous box when i click on another link, and vice versa.

  • 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-07T06:45:58+00:00Added an answer on June 7, 2026 at 6:45 am

    you have missed the # sign and please note that if the doctype of the page is not HTML5, id names must begin with a letter A-Z or a-z.

    $(".light").live("click", function(){ // you can also use `on()` instead of `live()` which is deprecated
        var id = this.id;
        $('div[id^="box"]').css({'background':'none'})
        $("#box"+id).css({'background':'red'});
    });
    

    DEMO

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

Sidebar

Related Questions

I have a menu that consist in five divs with a background image each.
I a template, I have five DIV elements underneath each other on a HTML
I am trying to space out DIVs. I have five DIVs that are 30px
I have a curious issue that's proving difficult. I have five divs stacked vertically
I have a Div with five float divs inside: var div=document.createElement(div); div.className=cssDivNino; var divFolio=document.createElement(div);
I have five text files that are produced by an R program, (each of
i have for example five divs, that has float:left and they are wrapped inside
I have five buttons on one form that when clicked enables a bool each
I have five map reduce that I am running each separately. I want to
I have five links that I want to change the content in the same

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.