jQuery and WordPress (Version 3.3.2)

I’ve added a new JavaScript file to the js directory in my custom theme and referenced it in header.php within the header block like so:

<script type="text/javascript" src="<?php bloginfo('template_url'); ?>/js/myScript.js"></script>

The content of the js file is to test a jQuery alert:

Read More
(function($) {

  $(document).ready(function(){
    alert('ready');
  });

})(jQuery);

I’ve tried multiple no-conflict solutions and my script is still ignored. I’m stumped, has anyone else fixed this? I’ve looked at a few different solutions from the past few years and they all seem to be bunko now.

I’ve even tried this within header.php before my script:

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

Any help is appreciated as I’m blocked for now.

Related posts

Leave a Reply

2 comments