Skip to content
  • Recent
  • Tags
  • Popular
  • Users
  • Search
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse

Lay Theme Forum

  1. Home
  2. General Discussion
  3. creating a simple accordion on a specific page

creating a simple accordion on a specific page

Scheduled Pinned Locked Moved General Discussion
2 Posts 2 Posters 700 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mrrpringle
    wrote on last edited by
    #1

    Hello,

    I've recently discovered the accordion feature and would love to implement this on my website as a button to hide/reveal information about my projects.

    I found a very minimal accordion solution on Codepen that I like: https://codepen.io/xengravity/pen/NPYzLY

    Now I'm trying to insert this code into my Laytheme website.

    I've copied the CSS in 'Custom CSS':

    #accordion li{list-style: none;}
    #accordion p{display:none;}
    #accordion .active{
    display:block;
    background:yellow;
    }

    And the Javascript in 'Custom <head> content':

    <script>
    $('#accordion li').click(function(){
    //hide inactive panels
    $(this).siblings().removeClass('active').children().removeClass('active');

    //display active panel
    $(this).addClass('active').children().addClass('active');
    

    })
    <script>

    I then copied the html and created a +HTML window on a specific page of my site and copied the HTML:

    <div id="accordion">
    <ul>
    <li class="active">Description
    <p class="active">bodyText</p></li>
    </ul>
    </div>

    But it's not working. I then copied the HTML in 'Custom <head> content' and was able to draw the accordion at the top of my screen, but there was no animation.

    What am I doing wrong here? How can I target this simple accordion in a specific page of my website? Feel like I am very close... Thank you for any and all feedback. I hope others who are new to coding will find this useful.

    1 Reply Last reply
    0
    • mariusjopenM Offline
      mariusjopenM Offline
      mariusjopen
      Global Moderator
      wrote on last edited by
      #2

      Dear @mrrpringle
      did you have a look here:
      http://laytheme.com/documentation.html#custom-javascript

      You need to use jQuery in a specific way.

      Best!

      Marius

      www.mariusjopen.world

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      I also code custom websites or custom Lay features.
      šŸ’æ Email me here: šŸ’æ
      info@laytheme.com

      Before you post:
      1. When using a WordPress Cache plugin, disable it or clear your cache.
      2. Update Lay Theme and all Lay Theme Addons
      3. Disable all Plugins
      4. Go to Lay Options → Custom CSS & HTML, click "Turn Off All Custom Code", click "Save Changes"

      This often solves issues you might run into

      When you post:
      1. Post a link to where the problem is
      2. Does the problem happen on Chrome, Firefox, Safari or iPhone or Android?
      3. If the problem is difficult to explain, post screenshots / link to a video to explain it
      Online Users
      A
      alasdair17
      Forgot your key, lost your files, need a previous Lay Theme or Addon version? Go to www.laykeymanager.com
      laytheme.com
      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Recent
      • Tags
      • Popular
      • Users
      • Search