0

i'm enqueuing jQuery with wp_enqueue_script( 'jquery' );

(i see

<script type='text/javascript' src='http://localhost/wp/wp-includes/js/jquery/jquery.js?ver=1.10.2'></script>
<script type='text/javascript' src='http://localhost/wp/wp-includes/js/jquery/jquery-migrate.min.js?ver=1.2.1'></script>

in the resulting html page)

now, i'm tryin to use:

$(document).ready(function() {
    $('#showmenu').click(function() {
            $('.menu').slideToggle("fast");
    });
});

and it only works if i add a jQuery reference manually (<script src="//code.jquery.com/jquery-1.10.2.js"></script>)

do i miss something?

1

Try this:

jQuery(document).ready(function() {
    jQuery('#showmenu').click(function() {
            jQuery('.menu').slideToggle("fast");
    });
});

Wordpress hates the $ statement. If you replace it with jQuery, it should work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.