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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T02:59:41+00:00 2026-05-31T02:59:41+00:00

Is it possible to compress this code below into few lines? There are similar

  • 0

Is it possible to compress this code below into few lines?
There are similar _jq_overlay_x and _jq_overlay_y statements for 8 different events. I think that will be better to compress those lines which will be better for optimization.

Thanks in advance

  $(document).ready(function(){
        $('#_jq_overlay_x').click( function(event) { 
            event.preventDefault(); 
            $('#_jq_overlay1').fadeOut(500); 
        });

        $('#_jq_overlay_y').click( function(event) { 
            event.preventDefault(); 
            $('#_jq_overlay1').fadeIn(500); 
        });
        $('#_jq_overlay_x').click( function(event) { 
            event.preventDefault(); 
            $('#_jq_overlay2').fadeOut(500); 
        });

        $('#_jq_overlay_y').click( function(event) { 
            event.preventDefault(); 
            $('#_jq_overlay2').fadeIn(500); 
        });
            $('#_jq_overlay_x').click( function(event) { 
            event.preventDefault(); 
            $('#_jq_overlay3').fadeOut(500); 
        });

        $('#_jq_overlay_y').click( function(event) { 
            event.preventDefault(); 
            $('#_jq_overlay3').fadeIn(500); 
        });
            $('#_jq_overlay_x').click( function(event) { 
            event.preventDefault(); 
            $('#_jq_overlay4').fadeOut(500); 
        });

        $('#_jq_overlay_y').click( function(event) { 
            event.preventDefault(); 
            $('#_jq_overlay4').fadeIn(500); 
        });
            $('#_jq_overlay_x').click( function(event) { 
            event.preventDefault(); 
            $('#_jq_overlay5').fadeOut(500); 
        });

        $('#_jq_overlay_y').click( function(event) { 
            event.preventDefault(); 
            $('#_jq_overlay5').fadeIn(500); 
        });
            $('#_jq_overlay_x').click( function(event) { 
            event.preventDefault(); 
            $('#_jq_overlay6').fadeOut(500); 
        });

        $('#_jq_overlay_y').click( function(event) { 
            event.preventDefault(); 
            $('#_jq_overlay6').fadeIn(500); 
        });
            $('#_jq_overlay_x').click( function(event) { 
            event.preventDefault(); 
            $('#_jq_overlay7').fadeOut(500); 
        });

        $('#_jq_overlay_y').click( function(event) { 
            event.preventDefault(); 
            $('#_jq_overlay7').fadeIn(500); 
        });
            $('#_jq_overlay_x').click( function(event) { 
            event.preventDefault(); 
            $('#_jq_overlay8').fadeOut(500); 
        });

        $('#_jq_overlay_y').click( function(event) { 
            event.preventDefault(); 
            $('#_jq_overlay8').fadeIn(500); 
        });
 });
  • 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-31T02:59:42+00:00Added an answer on May 31, 2026 at 2:59 am
    $(document).ready(function(){
        var elms=[];
        for (var i=1; i<=8;i++) {
            elms.push($('#_jq_overlay'+i)[0]);
        }
        $('#_jq_overlay_x').click( function(event) { 
            event.preventDefault(); 
            $(elms).fadeOut(500); 
        });
    
        $('#_jq_overlay_y').click( function(event) { 
            event.preventDefault(); 
            $(elms).fadeIn(500); 
        });
    });​
    

    Here’s a FIDDLE to show it working!

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

Sidebar

Related Questions

Is there any way to compress this css-selector? form#fiche-node-form.node-form input#edit-field-address-und-0-name.form-text, form#fiche-node-form.node-form input#edit-field-address-und-1-name.form-text, form#fiche-node-form.node-form input#edit-field-address-und-2-name.form-text,
I need to compress some binary files as quickly as possible with PHP -
Possible Duplicate: How do I calculate someone's age in C#? Maybe this could be
Possible Duplicate: HTML Compress File Upload? I have complains from client that my website
I am looking for a list of possible ways to compress files on Windows
Is it possible to configure java.util.logging to compress log files when it rolls onto
Would it be possible/practical to create a compression algorithm that splits a file into
Imagine, there are two same-sized sets of numbers. Is it possible, and how, to
In Python 2.5 I stored data using this code: def GLWriter(file_name, string): import cPickle
Possible Duplicate: How can I obfuscate JavaScript? Hi, I want to compress a JavaScript

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.