snippet

jQuery Accordion Demo by webdesignerhut

A simple content accordion built with jQuery


Tags: accordion panels accordion panels

The MIT License (MIT)

Copyright (c) 2017 webdesignerhut

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

jQuery Accordion Demo

A simple content accordion built with jQuery

Read tutorial here

  • Some Title
  • Duis eu enim turpis.

    Duis eu enim turpis. Interdum et malesuada fames ac ante ipsum primis in faucibus. Morbi eget lectus porttitor, dapibus mi porttitor, sollicitudin velit. Nam in sollicitudin tellus. Aliquam erat volutpat. Nunc pharetra ullamcorper pharetra. Pellentesque luctus lacus non pharetra consequat. Vivamus eget nisi venenatis, euismod lectus ut, sagittis ligula. Integer ultrices porta neque ut eleifend. In aliquet aliquam mauris, eu gravida massa vestibulum sed. Phasellus at nunc eu eros viverra placerat. Donec at sapien id augue tincidunt dapibus. Fusce elementum bibendum mollis. Praesent ac massa tempus, feugiat est ac, dapibus nunc. Vestibulum pulvinar tempus nunc, mattis pharetra dolor suscipit sed. Curabitur risus nibh, tempor in vehicula mattis, vulputate id ipsum.

  • Some other title
  • Interdum et malesuada fames ac ante ipsum primis in faucibus.

    Duis eu enim turpis. Interdum et malesuada fames ac ante ipsum primis in faucibus. Morbi eget lectus porttitor, dapibus mi porttitor, sollicitudin velit. Nam in sollicitudin tellus. Aliquam erat volutpat. Nunc pharetra ullamcorper pharetra. Pellentesque luctus lacus non pharetra consequat. Vivamus eget nisi venenatis, euismod lectus ut, sagittis ligula. Integer ultrices porta neque ut eleifend. In aliquet aliquam mauris, eu gravida massa vestibulum sed. Phasellus at nunc eu eros viverra placerat. Donec at sapien id augue tincidunt dapibus. Fusce elementum bibendum mollis. Praesent ac massa tempus, feugiat est ac, dapibus nunc. Vestibulum pulvinar tempus nunc, mattis pharetra dolor suscipit sed. Curabitur risus nibh, tempor in vehicula mattis, vulputate id ipsum.

  • And finally some more titles
  • Praesent fringilla vestibulum magna.

    Praesent fringilla vestibulum magna. Quisque posuere ac justo nec vestibulum. Cras pretium orci et lacus placerat, nec ultrices ipsum facilisis. Mauris ut est in mi hendrerit facilisis ut tristique velit. Vivamus vitae ullamcorper risus. Cras erat tortor, dapibus accumsan fringilla non, fermentum eu tellus. Quisque venenatis, lorem venenatis iaculis elementum, libero diam scelerisque mi, vel rhoncus nibh leo quis massa. Pellentesque a neque sit amet ante mattis imperdiet eget ut metus. Cras quam velit, ullamcorper molestie accumsan ac, porttitor ac quam. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse potenti. Nam id tellus risus. Morbi dapibus ipsum eu massa congue imperdiet. Sed et accumsan arcu, id lobortis nisl. Proin porttitor, libero ac rhoncus ullamcorper, orci libero tempus urna, non lacinia ipsum nulla sed sapien. Phasellus tempor vulputate pharetra.

/* CSS Document */ @import url(http://fonts.googleapis.com/css?family=Open+Sans); body { background: #2980b9; font-size:18px; line-height: 32px; color: #333; word-wrap:break-word !important; font-family: 'Open Sans', sans-serif; } h1 { font-size: 60px; text-align: center; color: #FFF; } h3 { font-size: 30px; text-align: center; color: #FFF; } h3 a { color: #FFF; } a { color: #FFF; } #accordion { margin:100px auto; padding:0; max-width:1160px; } #accordion li { list-style:none; } #accordion li.content { margin:0; padding: 20px; border: 1px solid #efefef; background: #FFF; } #accordion li.title { padding:10px; font-size:1.2em; line-height:2em; font-size: 26px; color:#FFF; background: #3498db; border-bottom: 1px solid #2980b9; } #accordion .hide { display:none; } #relatedContent { max-width: 800px; margin: 50px auto; } #relatedContent .item { max-width: 44%; padding: 3%; float: left; text-align: center; } #relatedContent .item a img { max-width: 100%; } // JavaScript Document $(document).ready(function() { $('#accordion li.content').filter(':nth-child(n+4)').addClass('hide'); $('ul').on('click','li.title',function() { $(this).next().slideDown(200).siblings('li.content').slideUp(200); }) });