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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T02:25:08+00:00 2026-05-24T02:25:08+00:00

I can’t find a post specifically for this (although I’m sure it exists and

  • 0

I can’t find a post specifically for this (although I’m sure it exists and I’m failing to find it.)

I have it so an image .regularpic toggles a whole specific div #title to appear upon clicking. Is there a more efficient way of having my code reset the other classes without all of those lines?

THE HTML IS THIS :

<img src="images/wordpress.png" alt="" class="regularpic first" />
<img src="images/google.png" alt="" class="regularpic second"  />
<img src="images/html5.png" alt=""  class="regularpic third" />
<img src="images/adobe.png" alt=""  class="regularpic fourth" />
<img src="images/jquery.png" alt=""  class="regularpic fifth" />

THE JQUERY IS THIS :

$(function() {
$(".first").click(
    function() {
    $(".second, .third, .fourth, .fifth").stop().animate({opacity:0.4 }, 500);
    $(".first").stop().animate({opacity:1.0 }, 500);
    $("#title2, #title3, #title4, #title5").stop()
                                           .animate({opacity:0.0, 
                                                     backgroundColor: '#fff',
                                                     color: '#fff',width: 580,
                                                     height:50}, 200);
        $("#title1").stop().animate({opacity:1.0, 
                                     backgroundColor: '#fff', 
                                     color: '#000', width: 580, 
                                     height: 300 }, 600);
                });
});
$(function() {
$(".first").click(
    function() {
    $(".first, .third, .fourth, .fifth").stop().animate({opacity:0.4 }, 500);
    $(".second").stop().animate({opacity:1.0 }, 500);
    $("#title1, #title3, #title4, #title5").stop()
                                           .animate({opacity:0.0, 
                                                     backgroundColor: '#fff',
                                                     color: '#fff',width: 580,
                                                     height:50}, 200);
        $("#title2").stop().animate({opacity:1.0, 
                                     backgroundColor: '#fff', 
                                     color: '#000', width: 580, 
                                     height: 300 }, 600);
                });
});

There has to be a more efficient way no?

  • 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-24T02:25:08+00:00Added an answer on May 24, 2026 at 2:25 am

    This sould do it for you :

    HTML :

    <img src="src" onClick="mypic('title1')" class="regularpic title1" />
    <img src="src" onClick="mypic('title2')" class="regularpic title2" />
    
        ...
    
    <img src="src" onClick="mypic('title5')" class="regularpic title5" />
    

    JQuery :

    var current = null;
    function mypic(id) {
        $('.regularpic').stop().animate({opacity:1.0 }, 500, function(){
            $('.title').stop().animate({ opacity:0.0, 
                                         color: '#fff', 
                                         height:50}, 500, function(){
                if(current !== id){
                    current = id; 
                    $('.'+id).stop().animate({opacity:0.7 }, 500);
                    $("#"+id).stop().animate({opacity:1.0, 
                                              color: '#000', 
                                              height: 300 }, 500);
    
                }
            });
        });
    };
    

    DEMO :

    http://jsfiddle.net/uEjct/4/

    Hope it helps.

    EDIT :

    You need to add a common class to :

    #title1,#title2,#title3,#title4,#title5
    

    In the example : class="title"

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

Sidebar

Related Questions

Can someone maybe tell me why this is not working? I have used echo
Can anyone help me trying to find out why this doesn't work. The brushes
can someone show me the regex for this preg_match. I want to make sure
Can't figure out how to do this in a pretty way : I have
Can anyone (maybe an XSL-fan?) help me find any advantages with handling presentation of
I have a jquery bug and I've been looking for hours now, I can't
Can anyone suggest how to underline the title of a UIButton ? I have
Can anybody tell me a regular expression to use within some PHP to find
Can I have a project that has some parts written in c and other
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

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.