-
AuthorPosts
-
August 30, 2014 at 2:34 am #311132
Hello,
I am trying to add my own customer jquery and have tried it in numerous locations in the theme files and nothing has seemed to initiate them
What file and where could I place custom jquery to where it will be initiated and run on load?
I am trying to add this
$(document).ready(function() {
$(“#nav1”).click(function() {
$(‘html,body’).animate({
scrollTop: $(“#why”).offset().top},’slow’);
});$(“#nav2”).click(function() {
$(‘html,body’).animate({
scrollTop: $(“#why2”).offset().top},’slow’);
});$(“#nav3”).click(function() {
$(‘html,body’).animate({
scrollTop: $(“#product”).offset().top},’slow’);
});$(“#nav4”).click(function() {
$(‘html,body’).animate({
scrollTop: $(“#how”).offset().top},’slow’);
});$(“#nav5”).click(function() {
$(‘html,body’).animate({
scrollTop: $(“#contact”).offset().top},’slow’);
});
});August 30, 2014 at 10:30 am #311208Hey!
Try adding this at the very end of your theme / child theme functions.php file:
function add_customjs() { wp_enqueue_script( 'customjs', get_stylesheet_directory_uri().'/js/custom.js', array('jquery'), 2, true ); } add_action( 'wp_enqueue_scripts', 'add_customjs', 100 );
Adjust as needed.
Cheers!
JosueSeptember 1, 2014 at 5:02 am #311648Thank you Josue, I’ll try it out!
September 1, 2014 at 5:04 am #311650You are welcome, let us know if you need something else :)
Regards,
JosueSeptember 19, 2014 at 8:50 pm #322104This reply has been marked as private.September 19, 2014 at 9:57 pm #322125Hey Colin!
The code i suggested was meant to be used in a child theme installation. Alternatively If you don’t want to do that yet; you can put any custom JS here (wrap it in <script></script> tags):
http://screencast.com/t/opsRshUq7RYCheers!
JosueJuly 29, 2015 at 12:32 pm #480148Dear Josue,
the screencast is down. Could you tell me where to put custom js code?
Thanks
BerndJuly 31, 2015 at 8:13 am #481127Hey Bernd!
I believe i was referring to the GA field in the Theme Options:
http://screencast.com/t/4X7FSZ7ipSRegards,
Josue -
AuthorPosts
- You must be logged in to reply to this topic.