Skip to content

Instantly share code, notes, and snippets.

@uddhabh
Created March 10, 2023 04:33
Show Gist options
  • Save uddhabh/41de4205454128fa2ad46c0600bf26cd to your computer and use it in GitHub Desktop.
Save uddhabh/41de4205454128fa2ad46c0600bf26cd to your computer and use it in GitHub Desktop.
Remembering Active Tabs in Elementor Nested Tabs using Local Storage and jQuery
<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