OK,
so I've got this weird situation. I'm trying to include Paul Underwood's simple smooth scroll script (http://www.paulund.co.uk/smooth-scroll-to-internal-links-with-jquery) in a Wordpress one-pager running on Wordpress 3.8.1. However, the smooth scroll ain't working.
The script works perfectly on JFiddle, I've checked it for errors, but it's a simple copy-paste from the source, so that shouldn't be the problem. I'm pretty sure I've enqueued it properly in functions.php (yes, I also registerd jQuery). And it should work in noConflict.
So what am I missing here? It won't surprise me if it's a stupid little mistake...
Anyway, thanks in advance everyone :)
The HTML:
<a href="#main"><img class="arrow" src="<?php bloginfo('stylesheet_directory'); ?>/images/arrow-down.png" alt="scroll down"></a>
The script:
jQuery(document).ready(function($) {
$(document).ready(function() {
$('a[href^="#"]').on('click',function (e) {
e.preventDefault();
var target = this.hash,
$target = $(target);
$('html, body').stop().animate({
'scrollTop': $target.offset().top
}, 900, 'swing', function () {
window.location.hash = target;
});
});
});
});
the functions.php
function my_scripts() {
wp_enqueue_script('jquery');
wp_enqueue_style( 'my-style', get_stylesheet_uri() );
wp_register_script( 'my-script', get_template_directory_uri().'/js/my-script.js', array('jquery'), '1.0', true );
wp_enqueue_script( 'my-script' );
}
add_action( 'wp_enqueue_scripts', 'my_scripts' );