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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:07:13+00:00 2026-05-28T06:07:13+00:00

So, on a web-page there are some components that have to be re-positioned whenever

  • 0

So, on a web-page there are some components that have to be re-positioned whenever the browser window is re-sized or scrolled.

$( window ).on( 'resize scroll', reposition );

where reposition is the function that does that.

However, that function has to be invoked immediately too. (By immediately, I mean on page initialization – inside DOM-ready.) This needs to be done to set up the initial positions of the components.

I’m currently doing it like so:

$( window ).on( 'resize scroll', reposition );
reposition();

I noticed that this also works:

$( window ).on( 'resize scroll load', reposition );

I believe this is reliable – the load is never fired before the DOMContentLoaded event.

But this delays the execution until after all page resources have been loaded (which could take a few seconds depending on how many images there are on the page). Is there any way to tell jQuery that the bound function should be invoked immediately too?

Like:

$( window ).on( 'resize scroll now', reposition );

or

$( window ).on( 'resize scroll ()', reposition );

These examples are of course invalid, but I was wondering if jQuery’s on method has such functionality. I guess, I could manually implement this functionality into on, but I’d like to first check if it has that already…

  • 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-28T06:07:14+00:00Added an answer on May 28, 2026 at 6:07 am

    You can do something like this:

    $(window).on('resize scroll', reposition).trigger('scroll');
    

    To set and trigger an event callback.

    Although you should be setting this in the $(document).ready just to be safe. Basically your code should look something like this:

    $(document).ready(function() {
        $(window).on('resize scroll', reposition).trigger('scroll');
    });
    

    So you’re guaranteed that the DOM will be ready for you to mess around with

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

Sidebar

Related Questions

Should a web application have a notices/about page that details the components/libraries that we
I have a web page with some javascript inside that will be embedded as
I have some localization problems in my webpage. There are basically two problems (that
Is there a way to enable in-browser editing of a web page, as done
I have dynamic web page with JS. There is a <textarea> and a Send
I have been asked to look into dynamic web page development, and there appears
Here's the problem....I have three components...A Page that contains a User Control and a
I have a silverlight control that opens up on a web page. But at
I have a basic jQuery webpage that shows off some basic features, however there
in web page ,image control and file upload are there.if click file upload and

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.