JQuery is not working in wordpress – Solution 2 comments


Recently i have seen some error in jQuery on WordPress 3.2.1.
Inside theme folder on header.php if i add

$(document).ready(function(){ alert(‘Pragnesh Karia’); });

Woilaa…..No alert found.
I have searched on google i found error was due to ‘$’.

closed.

That’s it.

In WordPress, the$() syntax is always used by other scripting library(Like prototype etc ), and causing the conflict issue and fail to call the jQuery function. You should use jQuery() instead…

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

Alternatively, you can use noConflict() …

$j=jQuery.noConflict();

// Use jQuery via $j(...)
$j(document).ready(function(){
  alert('test');
});

Share on Facebook




About Pragnesh Karia

Pragnesh Karia, Open Source Enthusiast, Software Professional, Software Developer, Technical Lead ,Magento, Joomla ,Joomla LMS , Moodel LMS ,PHP ,Mysql, Ajax, Javascript, Jquery, Linux, Fan of Open Sources , Annet Technologies , SEO Analyst , Mootools


2 thoughts on “JQuery is not working in wordpress – Solution