Skip to content

Instantly share code, notes, and snippets.

@md55
md55 / jquery.waituntilexists.js
Last active June 16, 2023 16:16 — forked from PizzaBrandon/jquery.waituntilexists.js
bugfix: if handler do waituntilexists() again with same selector then new IntervalId will replace old one in intervals array before removeListener() call. So new Interval will be cleared instead of old, and old Interval will never be cleared.
;(function ($, window) {
var intervals = {};
var removeListener = function(selector) {
if (intervals[selector]) {
window.clearInterval(intervals[selector]);
intervals[selector] = null;
}