简体   繁体   中英

Nice scroll to wordpress

I am converting html5 to wordpress Theme. I want to use custom scroll for wordpress. The code <script src="jquery.nicescroll.js"></script>

DEPENDENCIES It's a plugin for the jquery framework, you need to include jquery in your scripts.

I will use

"<?php wp_enqueue_script( $handle, $src, $deps, $ver, $in_footer ); ?>"

Will it work just by that What about below code?

$(document).ready(
  function() {
    $("html").niceScroll();
  }
);

EXAMPLES 1. Simple mode, it styles document scrollbar (html element prefered):

Where to enter this to make it work?

After enqueuing , do i need it again to add in header.php Explanation will be helpful.

If you are able to navigate your wordpress theme files you can easily add nice scroll file "jquery.nicescroll.js" into the theme where other js files is preferred and then register and enqueue it in the functions.php file

wp_register_script('nice-js',get_template_directory_uri() . '/assets/js/jquery.nicescroll.js',array('jquery'),'1.0.0',true );
wp_enqueue_script('nice-js');

and finally add it into the theme main js file

Like so:

$ = jQuery.noConflict();
$(document).ready(function() {
  //nicescroll
  $(function() {
      $("html").niceScroll();
  });
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM