You’ll find a file called functions.php
in your theme folder. Open it and add the following snippet:
function wpse_109027_enqueue_js() {
wp_enqueue_script(
'custom-script',
get_stylesheet_directory_uri() . "https://wordpress.stackexchange.com/js/script.js",
array( 'jquery' )
);
}
add_action( 'wp_enqueue_scripts', 'wpse_109027_enqueue_js' );
wp_enqueue_script
is used to add javascript files. The array('jquery')
part means that WordPress should load jQuery before loading your javascript file.
Note that WordPress loads jQuery in NoConclict Mode. You should therefore use jQuery noConflict Wrappers in your code:
jQuery(document).ready(function($){
$("#dd").change(function(){
var selected= $("#dd option:selected").text();
$('div').hide();
$('#'+ selected).show();
});
$('div').hide();
});