简体   繁体   中英

jQuery not loading in local wordpress install

Can anyone tell why my jQuery script is not loading here

<?php wp_enqueue_script("jquery"); ?>

<?php wp_head(); ?>

<script src="http://gsgd.co.uk/sandbox/jquery/easing/jquery.easing.1.3.js"></script>
<script type="text/javascript" src="<?php bloginfo('stylesheet_directory'); ?>/js/slides.jquery.js"></script>
<script type="text/javascript" src="<?php bloginfo('stylesheet_directory'); ?>/js/my-js-file.js"></script>

        <script>
        $(document).ready(function() {
                        $('#slides').slides({
                                preload: true,
                                preloadImage: 'img/loading.gif',
                                play: 5000,
                                pause: 2500,
                                hoverPause: true
                        });
                });
        </script>

</head>
<?php
function my_scripts_method() {
    wp_deregister_script( 'jquery' );
    wp_register_script( 'jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js');
    wp_enqueue_script( 'jquery' );
}    

add_action('wp_enqueue_scripts', 'my_scripts_method');
?>

Or simply use the latest version from jquery.com

<script src="http://code.jquery.com/jquery-latest.min.js"></script>

Good luck! :)

Not sure if the double quotes are what's causing the problem, it's a good idea to enqueue scripts for the front end via functions.php and not in header.php. Like so;

if ( !is_admin() ) {
wp_enqueue_script('jquery');
}

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