I say in theory that I am not an expert, but I achieved the desired result using its small (e), which should not be e lol
I get it. This is a way to pass the same event from one function to another.
Simply put. I wanted to make page navigation a flexible scroll function, but I wanted the page to be navigated "and" I wanted the same navigation to be available under certain conditions. I also need the same dynamic navigation from other click events that were not links. To save the current target and still use the navigation function, I had to set small (e) because jQuery will lose the $ (this) area as the same target of the lol function. Here is a brief example.
function navigate_to_page(e){ var target = $(e.currentTarget).attr('href'); //--This is the same as $(this) but more static to bring out of it scope $('html, body').animate({ 'scrollTop':$(target).offset().top-0, 'scrollLeft': $(target).offset().left-$(window).width()*0.0}, 2000, 'easeOutBounce'); }
Do not let the gibberish confuse you. This is just a simple page scroll animation. You should pay attention to e.currentTarget . e is our variable, and currentTarget is the jQuery equivalent of $ (this), so together they are a Globular $ (this) function. Now I call it another function with such conditions
$('#myNavigationDiv a').on('mouseenter', function(e){ if($(myCondition) === true){ return false; }else{ navigate_to_page(e); } });
See how small (e) knitted it all together?
Now you can replace (e) with (whatteverouant). By calling e in both functions, it maps to e .currentTarget, and you can apply this to any detailed specific functions you need and save LITERALLY pages of code lol
BRianIAK The Villain Dec 07 '13 at 5:10 2013-12-07 05:10
source share