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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T23:33:02+00:00 2026-05-23T23:33:02+00:00

If you mouseover class1a, then the CSS of class2a and class2b change. It’s the

  • 0

If you mouseover class1a, then the CSS of class2a and class2b change.

It’s the same pattern over and over again but the class names keep changing.

It’s resulting in a lot of code..I’m wondering if there’s a way to use jQuery to make it more
compact?

Note, I am obviously willing to change the class names…just have to be able to distinguish them as you see in this code…

$('.class1a').mouseover(function(){
   $('.class2a, .class2b').css( {height : '50px' , top: '75px'});
}).mouseout(function(){
    $('.class2a, .class2b').css({height : '25px' , top: '100px'});
  });

$('.class1b').mouseover(function(){
   $('.class2c, .class2d').css({height : '50px' , top: '75px'});
}).mouseout(function(){
    $('.class2c, .class2d').css({height : '25px' , top: '100px'});
  });
  • 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-23T23:33:03+00:00Added an answer on May 23, 2026 at 11:33 pm

    you can predefine variables with selectors and css objects that have multiple occurances, also you can use .hover() method

    var s1 = '.class2a, .class2b';
    var s2 = '.class2c, .class2d';
    var css1 = {height : '50px' , top: '75px'};
    var css2 = {height : '25px' , top: '100px'};
    
    $('.class1a').hover(function(){
        $(s1).css(css1);
    }, function(){
        $(s1).css(css2);
    });
    
    $('.class1b').hover(function(){
        $(s2).css(css1);
    }, function(){
        $(s2).css(css2);
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

$(document).ready(function() { $(span.link).mouseover(function(e){ $(this.children).css(display,inline); }); }); I'm not a javascript expert, but I've cobbled
I use jQuery mouseover to do something. But if I move mouse over about
I have a CSS mouseover slider fully functional here http://jsfiddle.net/gU4sw/13/ . When I add
I call the following function with a mouseover event but it's not working. My
I have always used the mouseover event, but while reading the jQuery documentation I
IF NOT mouseover/-enter/click on div menu THEN do stuff ELSE do other stuff? I
$('.star').mouseover(function (){ var star = $(this).index()1; $(this).parent().css(background-position,0 - (32 * star) px); }); $('.star-rating').mouseout(function
Here is my code for a mouseover: $('.caption').mouseover(function() { $(this).fadeTo('slow',1); $(this).css('color','#ddd').animate({'color': 'white'}, 500); $(this).css('font-weight','bold');
$(document).ready(function() { $(.MenuItem).mouseover(function() { // Remove second class and add another class [ Maintain
If I mouseover and mouseout .activate_tooltip once, it continues to work thereafter. But the

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.