Using VC Buttons as Collapsibles
-
Hello,
I’d like to use the “outline button” of the “Feature Section” for a different purpose than just linking to another page. I’d like to use the “raw HTML” and “raw Javascript” to make a collapsible out of it, expanding the function to the button by making an HTML class which I assigned. It partially works, next to the button is a “+” that turns into a “-” when I click on the button, which shows me that the code itself works. But no text is shown.
Can you help me there?
HTML: <button class="collapsible">Open Collapsible</button> <div class="content"> <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p> </div> CSS: .collapsible:after { content: '+'; color: white; font-weight: bold; float: right; margin-left: 5px; } .active:after { content: "-"; } .content { padding: 0 18px; max-height: 0; overflow: hidden; transition: max-height 0.2s ease-out; background-color: #f1f1f1; } Javascript: var coll = document.getElementsByClassName("collapsible"); var i; for (i = 0; i < coll.length; i++) { coll[i].addEventListener("click", function() { this.classList.toggle("active"); var content = this.nextElementSibling; if (content.style.maxHeight){ content.style.maxHeight = null; } else { content.style.maxHeight = content.scrollHeight + "px"; } }); }
I would’ve contacted the premium support for this, but it wants me to log in an Visual Composer account which I didn’t make? I just bought the license.
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Using VC Buttons as Collapsibles’ is closed to new replies.