Created
November 26, 2017 08:55
-
-
Save AndreaBarghigiani/b7f3167090663108f08d711502fd6c01 to your computer and use it in GitHub Desktop.
Corretta inclusione di un file JavaScript all'interno di WordPress. Maggiori informazioni: https://skillsandmore.org/usare-javascript-wordpress/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//Aggancio la funzione sam_script_styles() all'Hook wp_enqueue_script | |
add_action( 'wp_enqueue_scripts', 'sam_script_styles' ); | |
//Creo la funzione sam_script_styles() che mi permette di caricare i file JavaScript | |
function sam_script_styles() { | |
wp_enqueue_script( 'mio-js', get_stylesheet_directory() . '/js/mio-js.js', array( 'jquery' ), '1.0.0' ); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery(document).ready(function() | |
{ | |
function ScorriPagina(Posizione, Velocita) | |
{ | |
jQuery("html,body").animate({scrollTop: Posizione}, Velocita, function(){}); | |
return false; | |
} | |
jQuery(".torna-su").click(function() | |
{ | |
//Lo scroll avverrà per 0 pixel (e cioè posizione da raggiungere) ad una velocità di 1 secondo | |
ScorriPagina(0, 1000); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment