/ Published in: PHP
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
// Code in functions.php: function my_theme_scripts() { if ( !is_admin() ) { // instruction to only load if it is not the admin area // register your script location, dependencies and version wp_deregister_script( 'jquery' ); wp_register_script( 'jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js'); wp_enqueue_script( 'jquery' ); wp_register_script('custom_script', get_bloginfo('stylesheet_directory') . '/js/expand_collapse.js', '1.0' ); // enqueue the script wp_enqueue_script('custom_script'); } } add_action('init', 'my_theme_scripts'); // /js/expand_collapse.js in child theme: <script type="text/javascript"> jQuery(document).ready(function($) { $('#upNav').hide(); $('#showBtn').click(function() { $('#upNav').toggle(); }); $('#parent').hover(function() { $('#upNav').show(); }); $('#parentNav').mouseleave(function() { $('#upNav').hide(); }); }); </script>