Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript jQuery not responding once I move it to wordpress Re: jQuery not responding once I move it to wordpress

#64119
clokey2k
Participant

I have been staring at this one for some time now. Checking the script from ‘DOM ready’, comparing the scripts (and CSS :-) ). But now I have found it!!!

HTML 5 data- Attributes

As of jQuery 1.4.3 HTML 5 data- attributes will be automatically pulled in to jQuery’s data object.

You are including 1.4.2, so the ‘data-pos’ HTML attribute is ignored. So, either include a newer version of jquery or change:

jQuery("#mover").css("left", -($el.data("pos") * speed - 40));

to:

jQuery("#mover").css("left", -($el.attr("data-pos") * speed - 40));

BTW You can use ‘$’ to reference jquery while inside the :

jQuery(document).ready(function($) {
}

I also don’t think you need to use the no-conflict mode of jquery. If you are still loading the script via the deregister/register scripting in the ‘function.php’, as it unloads WordPress’s warped version of jQuery (but leaves the original jQuery for admin pages!).

I could be wrong, on all accounts – but I have learnt a few things while playing :-p