I have been working on implementing a jQuery code to expand a nested list. The functionality almost works as intended - when I click on the parent item, the nested list closes, and clicking again opens it. However, the issue arises when the page loads; I want the child list to start closed instead of open. So, my goal is for the initial state of the nested list to be closed.
jQuery(document).ready(function($) {
jQuery('li.parent').click(function() {
jQuery(this).children('ul').toggle();
return false;
});
});
Do you have any tips or additional code snippets that could help achieve the desired behavior?