Forums

jQuery not working in WordPress 2.7.1 (2 posts)

  1. patrickdd
    Member
    Posted 3 years ago #

    I have been trying to get jQuery to work in the latest version of WP but have had not luck at all.

    Here is a simple example of a script that will not work.

    <script type="text/javascript" src="<?php echo get_bloginfo('template_directory'); ?>/js/jquery-1.3.2.min.js"></script>
    
    <script type="text/javascript">
    jQuery(document).ready(
    function(){
    	jQuery("#portfolio").mouseover(function () {
    	  jQuery("#portfolio").fadeTo("slow", .8);
    	});
    
    	jQuery("#portfolio").mouseout(function () {
    	  jQuery("#portfolio").fadeTo("slow", 1);
    	});
    });
    </script>

    I have tried everything, including reinstalling WP. Nothing will work. I have no problem with my scripts working on normal HTML pages but none of them will work through WP. Any help would be greatly appreciated.

    Thanks!

  2. spstieng
    Member
    Posted 3 years ago #

    Have you tried Hello World?

    1. Doe this work?

    jQuery(document).ready(function() {
      alert('Hello world');
    });

    If no, see if you script is added.
    Test this by addingthe following to you js file

    function hello()
    {
      alert('Hello world');
    }

    In the php file, add:
    <a href="#" onClick="hello()">Link</a>

    If this doesn't work, then you javascript is not added.

    2. Does this work?

    jQuery("#portfolio").mouseover(function () {
    	  alert('Hello world');
    	});

    If no, and point 1. is yes, then start debuging..... :)

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags