Jump to content

smooth scrolling and scrollspy doesn't work


phn221181

Recommended Posts

hi, i made a small website for my wife.

i included jquery in order to use smooth scrolling and scrollspy. without success.

Someone can point me the mistake? i checked if i included jquery twice or more. i did not find.

 

i copied this code from w3schools:

<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<!--- Stuff between -->
<script>
    /* ### SCROLLING ### */
	// Add scrollspy to <body>
	$('body').scrollspy({target: ".navbar", offset: 50});

	// Add smooth scrolling on all links inside the navbar
	$('#myNavbar li a').on('click', function(event) {

	  // Make sure this.hash has a value before overriding default behavior
	  if (this.hash !== "") {

		// Prevent default anchor click behavior
		event.preventDefault();

		// Store hash
		var hash = this.hash;

		// Using jQuery's animate() method to add smooth page scroll
		// The optional number (800) specifies the number of milliseconds it takes to scroll to the specified area
		$('html, body').animate({
		  scrollTop: $(hash).offset().top
		}, 800, function(){

		// Add hash (#) to URL when done scrolling (default click behavior)
		  window.location.hash = hash;
		});

	  } // End if

	}); 	
 </script> 

 code explorer returns:

SCRIPT438: Object doesn't support property or method 'scrollspy'

check out:

this site

 

thanks in advance

pat

Edited by phn221181
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...