Saturday, 15 February 2014

jQuery script gives 'undefined is not a function' console error in WordPress -



jQuery script gives 'undefined is not a function' console error in WordPress -

this jquery snippet works fine in jsfiddle...

jquery(document).ready(function() { jquery(".link").click(function() { jquery('.content-container div').fadeout('slow'); jquery('#' + $(this).data('rel')).fadein('slow'); }); });

but when insert footer of wordpress site next error...

uncaught typeerror: undefined not function

anyone ideas doing wrong?

answer 7975203:

wordpress uses jquery in noconflict mode default. need reference using jquery variable name, not $, e.g. use

jquery(document);

instead of

$(document);

you can wrap in self executing function $ refers jquery 1 time again (and avoids polluting global namespace well), e.g.

(function ($) { $(document); }(jquery));

jquery wordpress

No comments:

Post a Comment