Home jQuery Browser Events jQuery Browser Events Index
About This Index This page is the jQuery Browser Events index for the tutorial track. Each row links to a full guide with syntax, examples, and FAQs.
Learn the jQuery overview on /jquery . Use this page when you need a browser event such as error , resize , or scroll .
Beginner path. Start with error for broken images, then resize and scroll—prefer .on() over the legacy shorthands.
Syntax
How to Call a Browser Event Bind with .on() and fire with .trigger()—same pattern as click or keydown:
$("img").on("error", function () {
$(this).attr("src", "/images/fallback.png");
});
$(window).on("resize", function () {
console.log($(window).width());
});
$(window).on("scroll", function () {
console.log($(this).scrollTop());
});
$(window).trigger("resize");
$(window).trigger("scroll"); Browse
jQuery Browser Events Table All Browser Events guides in this jQuery tutorial series (8 tutorials).
Resource Loading 2 methods Respond when a page resource fails — error on broken images, plus the legacy .error() shorthand.
Method Description Tutorial errorBind or trigger when an image or media element fails to load — attach before setting src and use a valid fallback. Try it .error()Legacy shorthand removed in jQuery 3.0 — migrate to .on('error') and .trigger('error'). Try it
Document / Resource Load 2 methods Run code when window, images, or iframes finish loading — the load event and the removed .load() shorthand.
Method Description Tutorial loadBind when window, images, or iframes finish loading — attach before src and don't confuse with Ajax .load(url). Try it .load()Event shorthand removed in jQuery 3.0 — migrate to .on('load'); Ajax .load(url) is a different method. Try it
Window Size 2 methods React when the viewport changes — resize on window; debounce expensive layout work.
Method Description Tutorial resizeBind or trigger when the browser window changes size — debounce handlers and read $(window).width(). Try it .resize()Deprecated since jQuery 3.3 — migrate to .on('resize') and .trigger('resize') on window. Try it
Frequently Asked Questions What are jQuery browser events? They cover window and resource lifecycle: error when an image fails to load, resize when the viewport changes size, and scroll when window or overflow elements move. Bind them with .on() like other jQuery events.
Should I use .on('resize') or .resize()? Prefer .on('resize', handler) and .trigger('resize'). The .resize(), .scroll(), and .error() shorthands are deprecated or removed in modern jQuery—migrate to the .on() / .trigger() forms.
Can I use the error event for JavaScript exceptions? No. Element error (broken images) is different from window script errors. Use window.onerror or addEventListener('error', ...) for uncaught exceptions—not $(window).on('error').
How do I avoid an infinite error loop on images? Bind before setting src, then swap to a known-good fallback URL. Use .one('error') or remove the handler after the swap so a bad fallback cannot retrigger forever.
Where should I start? Start with the error event for broken images, then resize and scroll. Prefer .on() bindings over the legacy shorthands.
Start with error Open the error event guide—syntax, examples, and FAQs.
error tutorial → CODETOFUN NEWS
Stay Ahead in Tech Get the latest IT news, programming updates, and technology trends directly on your phone.
About the author Developer, cloud engineer, and technical writer
I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.
16 people found this page helpful
Helpful Share Copy link Suggestion