+ 2

Can I manually code the accordion without downloading and including jQuery files ?

20th May 2017, 3:25 AM
Jeric So
Jeric So - avatar
3 Réponses
+ 4
You can manually code anything which is in any framework/library, as they just provide you ready to use codes, but someone write it manually ;) @James link provide solution for do it without "JQueryUI" ( an extention to JQuery ), but can be easily translate to vanilla ( pure -- without libraries ) JS ( without animation effects: require some more adaptations ^^ ): window.onload = function() { var accordions = document.querySelectorAll('#accordion .accordion-toggle'); for (var i=0; i<accordions.length; i++) { accordions[i].onclick = function(){ // Hide the other panels // ( at first: avoid testing wich is not to hide :P ) var contents = this.parentElement.getElementsByClassName('accordion-content'); for (var i=0; i<contents.length; i++) { contents[i].className = 'accordion-content'; } // Expand or collapse this panel this.nextElementSibling.className = 'accordion-content default'; }; } }; Complete code here ( but css and html unchanged ^^ ): https://code.sololearn.com/W86rM5c1y6uJ/#js
20th May 2017, 7:13 AM
visph
visph - avatar
+ 1
I made an accordion with pure CSS and HTML https://code.sololearn.com/WvHqvisioSJU/#html
4th Mar 2018, 2:34 PM
Lil Taco
Lil Taco - avatar
0
Thanks😀
20th May 2017, 8:08 AM
Jeric So
Jeric So - avatar