diff --git a/js/theme.js b/js/theme.js
index 53432474..40053aac 100644
--- a/js/theme.js
+++ b/js/theme.js
@@ -264,34 +264,39 @@ if (downloadNote.length >= 1) {
//This code handles the Expand/Hide toggle for the Docs/Tutorials left nav items
-$("#pytorch-left-menu p.caption").each(function(){
- var collapsedSections = ['Notes'];
- var menuName = this.innerText.replace(/[^\w\s]/gi, '').trim();
- if (collapsedSections.includes(menuName) == true && $(this).children().not(".expand-menu")) {
- $(this).children("span").after("[ + ]");
- $(this).children("span").after("");
- $(this).next("ul").hide();
- }else{
- $(this).children("span").after("");
- $(this).children("span").after("[ + ]");
- }
- })
+$( document ).ready(function() {
+ var caption = "#pytorch-left-menu p.caption";
+ var collapseAdded = $(this).not('checked');
+
+ $(caption).each(function(){
+ var menuName = this.innerText.replace(/[^\w\s]/gi, '').trim();
+ $(this).find("span").addClass('checked');
+ if (collapsedSections.includes(menuName) == true && collapseAdded) {
+ $(this.firstChild).after("[ + ]");
+ $(this.firstChild).after("");
+ $(this).next("ul").hide();
+ }else if (collapsedSections.includes(menuName) == false && collapseAdded){
+ $(this.firstChild).after("[ + ]");
+ $(this.firstChild).after("");
+ }
+ })
-$(".expand-menu").on("click", function() {
- $(this).next(".hide-menu").toggle();
- $(this).parent().next("ul").toggle();
- toggleList(this);
-});
+ $(".expand-menu").on("click", function() {
+ $(this).prev(".hide-menu").toggle();
+ $(this).parent().next("ul").toggle();
+ toggleList(this);
+ });
-$(".hide-menu").on("click", function() {
- $(this).prev(".expand-menu").toggle();
- $(this).parent().next("ul").toggle();
- toggleList(this);
-});
+ $(".hide-menu").on("click", function() {
+ $(this).next(".expand-menu").toggle();
+ $(this).parent().next("ul").toggle();
+ toggleList(this);
+ });
-function toggleList(menuCommand) {
- $(menuCommand).toggle();
-}
+ function toggleList(menuCommand) {
+ $(menuCommand).toggle();
+ }
+});
// Get the card link from the card's link attribute