-1

This question already has an answer here:

i created custom page template where i inserted followed JQuery script.

<script type="text/javascript">
$( document ).ready(function() {
console.log( "ready!" );
});
</script>

But it wont work. I get Object expected error. Jquery is inserted on page header so it should be loaded.

Why is that not working?

marked as duplicate by fuxia Mar 29 '17 at 19:49

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 1
    You should post the complete text of the error, for more clarity. – AncientRo Mar 29 '17 at 19:37
0

The version of jQuery distributed with WP runs in noConflict() mode (meaning that $ is not bound to the jQuery object).

Thus, you should do:

<script type="text/javascript">
    jQuery( document ).ready(function() {
        console.log( "ready!" );
    });
</script>

or

<script type="text/javascript">
(function ($) {
    $( document ).ready(function() {
        console.log( "ready!" );
    });
})(jQuery) ;
</script>

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