JQuery Accordion
-
Sorry to bother, but I am having trouble getting the JQuery accordion to work on my Child Theme.
I have created a new functions.php file to register and then enqueue the relevant scripts on my page:
function add_accordion() { wp_enqueue_script( 'add-accordion', get_template_directory_uri() . '/js/accordion.js', array('jquery-ui-core', 'jquery-ui-accordion') ); } add_action( 'wp_enqueue_scripts', 'add_accordion' );I have created a custom accordion.js file saved in a folder called js, which is in turn saved in the root folder of the child theme:
//Accordion Widget jQuery(document).ready(function($) { $( "#accordion" ).accordion(); });I have used the following mark up in my HTML:
<div id = "accordion"> <h3>Header 1</h3> <div> <p> Content 1 Content 1 Content 1 </p> </div> <h3>Header 2</h3> <div> <p> Content 2 Content 2 Content 2 </p> </div> <h3>Header 3</h3> <div> <p> Content 3 Content 3 Content 3 </p> </div> <h3>Header 4</h3> <div> <p> Content 4 Content 4 Content 4 </p> </div> </div>However, I am not getting any response.
Could you please let me know where I am going wrong?Thanks so much!
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
The topic ‘JQuery Accordion’ is closed to new replies.