Created
March 10, 2023 04:33
-
-
Save uddhabh/41de4205454128fa2ad46c0600bf26cd to your computer and use it in GitHub Desktop.
Remembering Active Tabs in Elementor Nested Tabs using Local Storage and jQuery
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
jQuery(document).ready(function () { | |
localStorage.removeItem('data-tab-index"') | |
jQuery(".child-tab .e-n-tab-title").click(function () { | |
localStorage.setItem("data-tab-index", jQuery(this).attr("data-tab")) | |
}) | |
jQuery(".parent-tab .e-n-tab-title").click(function () { | |
window.setTimeout(function () { | |
console.log(localStorage.getItem("data-tab-index")) | |
if (localStorage.getItem("data-tab-index")) { | |
jQuery(".child-tab .e-n-tab-title").removeClass("e-active") | |
// console.log(jQuery(".child-tab .e-n-tab-title[data-tab='" + localStorage.getItem("data-tab-index") + "']")) | |
jQuery(".child-tab .e-n-tab-title[data-tab='" + localStorage.getItem("data-tab-index") + "']").addClass("e-active") | |
} | |
}, 10) | |
}) | |
}) | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment