I’m try to use jQuery in 2011 WordPress theme I added this to the header:
wp_enqueue_script( 'jquery' );
and tested using this:
<script type="text/javascript">
$(document).ready(function(){
alert("test");
});
</script>
I also used jQuery instead of $ but this did not work.
Please help, thanks
I literally just had this issue on WordPress the other day. I solved it simply by adding my script to the header, and making certain that jQuery was running.
Instead of writing your script directly in the header, it might be better to link to an external file (example):
<script type="text/javascript" src="http://yourwebsite/javascripts/.js"></script>
Host it somewhere on your server and then link to it – if it contains event handlers, they should bind without a problem.
Put this code in the theme function.php:
Put this code inside ( section) of your header.php file of your theme.
Now you can call
In this way you are ready to use jquery into your theme.