Joshua
Joshua

Reputation: 95

"TypeError: $(...) is null" What's Going On?

Firebug is giving the error:

TypeError: $(...) is null
$('#menu img').hover(

I have no idea why. The seemingly problematic script is this which replaces an image when the cursor hovers over an image:

$(document).ready(function()
{
    var storeNormalPath;
    $('#menu img').hover(
        function()
        {   
            storeNormalPath = $(this).attr('src');
            var imgArray = $(this).attr('src').split('.jpg');
            $(this).attr('src', imgArray[0]+'Hover.jpg');
        }, 
        function() 
        {   
            $(this).attr('src', storeNormalPath);
        }
        ).click (function()
        {
            //empty now
        });
});

Upvotes: 4

Views: 24694

Answers (1)

dayala
dayala

Reputation: 108

After some looking over your page using chrome's console, it looks that even $(document) is returning null. jQuery(document) however, works, which suggests there is something in conflict with jQuery's $ operator.

(Source: I would direct you to this question: $.document is null)

Seeing that you have both jquery-1.5.1.min.js AND jquery.1.4.2.js referenced in your page header, perhaps that could be the reason of the conflict? Have you tried loading only one of them?

Let us know if that helps, sorry I couldn't be more help. Good luck!

Upvotes: 6

Related Questions