8

I am getting an : Uncaught TypeError: Property '$' of object [object DOMWindow] is not a function error in Chrome with my script.

<script type="text/javascript"> 
    function showSlidingDiv() {
        $("#slidingDiv").fadeToggle("slow", "linear");
    }
    function showSlidingDiv2() {
        $("#slidingDiv2").fadeToggle("slow", "linear");
    }         
    function showSlidingDiv3() {
        $("#slidingDiv3").fadeToggle("slow", "linear");
    }
</script> 

Does anyone know what could be wrong here?

radbyx
  • 9,352
  • 21
  • 84
  • 127
Jasper
  • 81
  • 1
  • 1
  • 2

5 Answers5

18

Chrome does load other libraries that make the use of $ symbol on other purposes, so you have to use jquery no conflict. on of the way is to change the $ symbol with jQuery

$(function(){...});

change to

jQuery(function(){...});
oers
  • 18,436
  • 13
  • 66
  • 75
sanusi
  • 181
  • 1
  • 2
6

My guess is that jquery was not loaded before run of one of these methods, so or it's not included before run of these methods, or there's some error causing it to not load properly. Normally this should "just work" (at least not throw that kind of error message)

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript"> 
    function showSlidingDiv() {
        $("#slidingDiv").fadeToggle("slow", "linear");
    }
    function showSlidingDiv2() {
        $("#slidingDiv2").fadeToggle("slow", "linear");
    }         
    function showSlidingDiv3() {
        $("#slidingDiv3").fadeToggle("slow", "linear");
    }
</script> 
petho
  • 677
  • 4
  • 10
1

No mather the time.. I found a solution that worked for me.

Instead of

$("#slidingDiv")

try

jQuery("#slidingDiv")

the other options weren´t usefull for me.

George
  • 371
  • 5
  • 16
0
<script type="text/javascript"> 
var j = jQuery;
function showSlidingDiv() {
    j("#slidingDiv").fadeToggle("slow", "linear");
}
function showSlidingDiv2() {
    j("#slidingDiv2").fadeToggle("slow", "linear");
}         
function showSlidingDiv3() {
    j("#slidingDiv3").fadeToggle("slow", "linear");
}
</script> 
Rameez SOOMRO
  • 1,529
  • 15
  • 24
0

make sure jQuery.noConflict() isn't being called. Calling it won't allow the use of the $ shorthand notation.

ContextSwitch
  • 2,830
  • 6
  • 35
  • 51