Link to home
Start Free TrialLog in
Avatar of Robert Granlund
Robert GranlundFlag for United States of America

asked on

jQuery Syntax

Can I write a function that is if page is scrolled or if page is resized?  If so, what is the syntax/example of how I would write that?  Also, is there a better way to go about this?
Avatar of Shaun Vermaak
Shaun Vermaak
Flag of Australia image

https://api.jquery.com/resize/
$( window ).resize(function() {
  $( "#log" ).append( "<div>Handler for .resize() called.</div>" );
});

Open in new window


https://api.jquery.com/scroll/
$( "#target" ).scroll(function() {
  $( "#log" ).append( "<div>Handler for .scroll() called.</div>" );
});

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Mikkel Sandberg
Mikkel Sandberg
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial