Click here to Skip to main content
15,886,919 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello, i have this code:

Java
<script> document.addEventListener("DOMContentLoaded", function(event) {   jQuery('.elementor-tab-title').removeClass('elementor-active');   jQuery('.elementor-tabs').css('display', 'none'); }); </script>


which hides a css element as soon as the page loads.

how can i show/hide
.elementor-tabs
when i click a button?

What I have tried:

I've tried all i can think off, but as its not a div im not sure. Any ideas?
Posted
Updated 30-Apr-18 23:22pm

1 solution

Create your button in HTML:
HTML
<button id="elementorTabsButton">Button text</button>

And your JavaScript:
JavaScript
jQuery("#elementorTabsButton").click(function() {
    jQuery(".elementor-tab-title").toggleClass("elementor-active");
    jQuery(".elementor-tabs").toggle();
});

"toggleClass" adds or removes a class, depending on if it's there or not.
"toggle" shows or hides an element.

Side node: you can write $ as a short-hand for jQuery.
 
Share this answer
 
v2
Comments
OfficalCodexPH 1-May-18 5:45am    
Chhers bro

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900