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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T15:13:24+00:00 2026-06-14T15:13:24+00:00

I have the following markup and am doing some jQuery mouseovers and am going

  • 0

I have the following markup and am doing some jQuery mouseovers and am going to set the background-color. I’d also like to set the background-color of the adjacent class if the class is a .list_spacer

I currently have:

<div class='lists_items'>
<div class='list_item'>info here</div>
<div class='list_spacer'></div>
<div class='list_item'>info here</div>
<div class='list_spacer'></div>
<div class='list_item'>info here</div>
<div class='list_spacer'></div>
<div class='list_item'>info here</div>
</div>

$('.list_item').on('mouseover',function(){
  $(this).css('background-color','yellow'); // <- yeah, the simplest possible scenario
});

And am thinking there must be some way of accessing adjacent divs and setting only if of a certain class but don’t know how. Any ideas on how to do this? I only want to select if immediately before or after and has class of list_spacer

thx in advance

  • 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-14T15:13:25+00:00Added an answer on June 14, 2026 at 3:13 pm

    You could user .prev and .next methods to access adjacent tags.

    Example:

    $('.list_item').on('mouseover',function(){
      $(this).prev().css('background-color','yellow');
    });
    

    To access a certain class, use:

    $('.list_item').on('mouseover',function(){
      $(this).prev('.list_spacer').css('background-color','yellow');
    });
    

    You also can access parent tags:

    <div class='list_item'>
         <div class='list_spacer'></div>
    </div>
    
    $('.list_spacer').parent().css('background-color','yellow');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jQuery accordion with the following markup <div id=accordion> <div class=group id=1>
I have the following markup: <div id=routes> <ul id=routesList> <li class=routes>Route 1</li> <li class=routes>Route
I have the following markup: <p class=managebox> <button value=Add page> <img src=page_add.png alt=Add more
I have the following markup - <div class=area 1 friendly> <div class=area-count> 8 </div>
I have the following markup: <li id=fragment-3 class=slides virtualsation ui-tabs-panel style=> <h1>Virtualisation</h1> <p>By implementing
I have the following markup for my input fields: <div class=required> <label for=Name>Name <em>*</em></label>
I have the following markup: <div class="header">Text</div> <div class="hiddenArea">sdsada</div> <div class="header">Text2</div> <div class="hiddenArea">sdsada</div> and
I have the following markup; <tbody> <tr> <td class=expand>Showroom area - New Display Zone</td>
I have the following markup: <div class=FixedHeightContainer> <h2>Title</h2> <div class=Content> ..blah blah blah... </div>
I have the following markup: <table class=dogs> <tr> <td> <input class=name> </td> etc. I’m

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.