Conflict with other jQuery code
-
Hey there!
I am using your plugin, which is working like a charm. Now I’ve added some jQuery code for smooth scrolling to anchors to a specific page on my site and I’m receiving errors. I tried to figure out, how to avoid this, but didn’t get any further. So maybe you could help me?! 🙂
I’m using latest version of your plugin and I’m running this code:
jQuery(document).ready(function($){ if(window.location.href.indexOf("tradition") > -1) { $('a[href^="#"]').on('click',function (e) { e.preventDefault(); var target = this.hash, $target = $(target); $('html, body').stop().animate({ 'scrollTop': $target.offset().top }, 900, 'swing'); }); } });which only comes to effect, when “tradition” page is being loaded.
While your plugin is working on the other pages perfectly fine, debugger returns this error:
TypeError: $target.offset(...) is undefinedwhen my code gets loaded and the plugin stops working.Any idea? :/
Cheers!
The topic ‘Conflict with other jQuery code’ is closed to new replies.