I want to add something like this to a WordPress page: (fiddle)
var div = $('#move');
var upper = $('#up');
var downer = $('#down');
upper.click(function() {
div.animate( { top: '-100'}, 500);
});
downer.click(function() {
div.animate( { top: '0'}, 500);
});
I know how to add the divs and the CSS to get that all working correctly, but I can’t seem to figure out how to add the JavaScript to make the two divs (up and down) to work correctly. I can’t seem to find anything on adding that code to the footer as well. From what I understand, the only way to have functionality like that is to have the code in the footer.
I tried a few different solutions, but none of them seem to work.
The name of the file is java.js that I have the functions stored in
<script type="text/javascript" src="<?php bloginfo('template_url'); ?>wp-content/themes/kallyas/js/java.js"></script>
I placed that in footer.php right after the closing body tag, but again didn’t work.
I may have the path wrong. From the base of the wordpress install, I have it here: wp-content/themes/kallyas/js/java.js
Add this to your functions.php file:
Remove the script loading from
header.php
, and also remove any jQuery loading from it. Then, you can usewp_enqueue_script
to make your JS file load at the footer and to force the inclusion of other files (jQuery in this case) as dependencies.Add to your
functions.php
file:PS: Donât Dequeue WordPressâ jQuery and if you do it, do it correctly with Use Google Libraries.