I run a wordpress blog.
It includes Jquery
<script type='text/javascript' src='/wp-includes/js/jquery/jquery.js?ver=1.12.3'></script>
<script type='text/javascript' src=/wp-includes/js/jquery/jquery-migrate.min.js?ver=1.4.0'></script>
When I run jQuery
I got:
function (a,b){return new n.fn.init(a,b)}
when I try
$("div")
I got
Uncaught TypeError: $ is not a function(â¦)
when I try jQuery("div")
I got:
a.fn.init[203]
How can I use Jquery ?
$
is an alias of thejQuery()
function, which apparently missing in this case…One way is to do, between jQuery and your other scripts:
It should work
As others have told you, this is due to
jQuery.noConflict
. You can use a Immediately-Invoked Function Expression to map the$
variable tojQuery
and simply place your logic inside of the expression:It looks like jQuery is not bound to the
$
variable (to avoid conflicts, probably).If you want to use the
$
variable then you can create a scope wherein it will be bound to that variable:If all your code should run when the document is ready (which is usually how it is done) then you can also use the scope that jQuery creates for you:
You can also just add jQuery to a global
$
variable. If you know for certain that only jQuery will be using that variable then it is probably fine.