Any idea how I can make a function be called only once using .resize, and then have it permanently cancelled or disabled?
$(window).resize(function () {
if ($(window).width() < 800) {
size = true;
mob();
}
});
UPDATE: Great stuff, thanks sdespont – got it to work with on/off:
$(window).on('resize',function () {
if ($(window).width() < 800){
agent = true;
mob();
}
});
then turn off the resize function once the condition is met:
$(window).off('resize');
Use
onefunction http://api.jquery.com/one/Or
on/offfunctions http://api.jquery.com/on/