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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:52:56+00:00 2026-05-25T10:52:56+00:00

Trying to fade in a container once the image has been loaded, resized, and

  • 0

Trying to fade in a container once the image has been loaded, resized, and hidden a few elements, but am running into issues.

My console isn’t showing any errors.. but the functions arn’t executing

The commented out code worked perfectly.

Test site:

http://brantley.dhut.ch/

JavaScript:

/*jQuery(function($) {
    $('.z').respond();
});*/

$(document).ready(function() {
    //$('#two, #three, #four').hide();
    //$('#main').fadeIn('slow');

    $('.z').respond(function() {
        $('#two, #three, #four').hide();
        $('#main').fadeIn('slow');
    });

    $('.z').click(function() {
        var slide = $(this);
        slide.fadeOut(600, function() {
            slide.next().fadeIn(600);
            slide.insertAfter('.z:last');
        });
    });
});

Plugin:

(function( $ ){
    $.fn.respond = function() {

        /* initialize function on window load and resize */
        $(document).ready(function() {
            dimensions();
        });
        $(window).load(function() {     
            dimensions();
        });
        $(window).resize(function() {
            dimensions();
        });

        /* declare affected elements */
        var pic = this

        /* set image's height or width depending on the browser window's size */
        function dimensions() {
            return pic.each(function() {

            /* declare variables */
                var browserWidth = $(window).width();
                var imgRatio = $(this).width() / $(this).height()
                var availableHeight = ($(window).height() - $('header').height() - $('footer').height() - 80)
                var browserRatio = browserWidth / availableHeight

                /* image sizing logic */
                if (browserRatio >= imgRatio) {
                    if (browserWidth > 640) {
                        /* if the browser is landscape and bigger than mobile, set the image's height to fill the available space */
                        $(this).height(availableHeight).width('auto');
                        //$('body').css('background', 'blue');
                    } else {
                        /* it's mobile */
                        $(this).width(browserWidth - 40).height('auto');
                        //$('body').css('background', 'red');
                    }
                } else {
                    /* if the browser is portrait, set the image's width to fill the page */
                    $(this).width(browserWidth - 40).height('auto');
                    //$('body').css('background', 'green');
                }

                /* horizontally center content */
                $(this).css('margin-left', (browserWidth - $(this).width())/2);

            });

        };

    };
})( jQuery );
  • 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-25T10:52:57+00:00Added an answer on May 25, 2026 at 10:52 am

    your plugin has no callback defined, which is why nothing is happening.

    change: $.fn.respond = function() {

    to: $.fn.respond = function(callback) {

    and add: callback(); at the end of the plugin.

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

Sidebar

Related Questions

I'm trying to have images fade in with css3 once they're loaded. The problem
i'm trying to fade a few hidden divs in on hover and out on
I'm trying to fade all elements on a webpage except for one div. I've
I'm trying to fade in my menu bar after an empty div is loaded
I am trying to fade an image in a canvas environment. Essientially what I
I'm trying to fade in a hidden element based on the href attribute of
I am trying to fade a box in by using an image with a
I'm trying to fade in the div frame1 in while frame2 is hidden, and
I'm trying to fade in a div when it scrolls into view from 0.4
I'm trying to add Fade-In Fade-out effects to the homepage of this page but

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.