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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T21:56:38+00:00 2026-06-03T21:56:38+00:00

Currently, I do stuff when the mouse moves. However, I also want to do

  • 0

Currently, I “do stuff” when the mouse moves. However, I also want to do the exact same thing if the user resizes the browser or scrolls down the browser.
jQuery(document).bind(‘mousemove’,function(e){
var x, y;
x = e.pageX; // x coord
y = e.pageY; // y coord
//other stuff
});

I tried putting doing

jQuery(document).bind('mousemove resize scroll',function(e){...

but it didn’t work. I also tried

jQuery(document, window).bind('mousemove resize scroll',function(e){...

but it also didn’t work.

I also know that you can detect scroll using

$(window).scroll(function(){

and detect resize using

$(window).resize(function() {

But the if I use those detections, I won’t have the “e” argument to get the x and y coordinates of the mouse

How do I bind all 3 events all into one function?

Thanks

  • 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-06-03T21:56:40+00:00Added an answer on June 3, 2026 at 9:56 pm

    You do still have the event data in the scroll and resize methods. Try wrapping your code into a single function with 3 handlers. The on() method requires jQuery 1.7+

    function reusable(eData){
        // Heres what you want to do every time
    }
    $(document).on({
        mousemove: function(e) { reusable(e); },
        scroll   : function(e) { reusable(e); }
    );
    $(window).on({
        resize   : function(e) { reusable(e); }
    });
    

    edited

    The events should be in their correct objects window and document or you will get unexpected values.

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

Sidebar

Related Questions

I want to get into Erlang programming, specifically some yaws stuff. (Currently, I use
Im currently trying to learn some stuff about encryption, it's algorithms and how it
I am currently messing around with some stuff for an idea for a site
I'm currently having a problem in displaying some stuff in ListView . I have
I'm currently developing a Web platform app in HTML and PHP stuff. I have
We have some stuff that may be exported into various formats. Currently we have
Hi guys! Currently discovering cocos2d framework. Now I'm trying to use UIKit stuff in
Some background first. I am currently learning some stuff about monadic parser combinators. While
I'm currently diving into node.js stuff starting with very simple examples. The following code
I am currently trying to learn some more in depth stuff of file formats.

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.