ukscotth Posted December 5, 2014 Share Posted December 5, 2014 Hi, I have the following code which gives a fading out effect when clicking on links. I need to be able to disable it for anchor links so it is disabled when using # as the link. Any ideas ? /* * Function to animate leaving a page */ $.fn.leavePage = function() { this.click(function(event){ // Don't go to the next page yet. event.preventDefault(); linkLocation = this.href; // Fade out this page first. $('body').fadeOut(400, function(){ // Then go to the next page. window.location = linkLocation; }); }); }; Thanks, Scott. Link to comment https://forums.phpfreaks.com/topic/292908-animate-leaving-a-page-code-modification/ Share on other sites More sharing options...
Alex_ Posted December 6, 2014 Share Posted December 6, 2014 Not sure I understood exactly what you meant, but I'm assuming a tag like this.. <a href="#">Link</a> You do not want it to process the code? If so, you could just wrap the current code inside the click eventhandler with an if-statement. if(this.href !== '#') { ... //Your code here } Or matching it for cases like href="#/link/here"> if(this.href.indexOf('#') === -1) { ...//Your code here } If I missunderstood, just let me know. Link to comment https://forums.phpfreaks.com/topic/292908-animate-leaving-a-page-code-modification/#findComment-1498758 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.