• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

Problems with Genesis + Javascript

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › General Discussion › Problems with Genesis + Javascript

This topic is: resolved

Tagged: genesis, javascript, jquery, problems

  • This topic has 12 replies, 2 voices, and was last updated 7 years, 8 months ago by Eric Emanuel.
Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • December 28, 2015 at 7:21 pm #174989
    Eric Emanuel
    Member

    Hello, everyone!

    I'm pretty new in webdesign and specially with Genesis, still trying to figure out how it works. i'm trying to run a very simples 'expand and collapse' javascript file in a site i'm testing locally but can't manage to make it work.

    I've already loaded the file in my functions.php using this:

    add_action( 'wp_enqueue_scripts', 'kme_load_scripts' );
    function kme_load_scripts(){
    
    	wp_enqueue_script('kmeexpandcollapse', get_stylesheet_directory_uri() . '/js/kmeexpandcollapse.js', array('jquery'), '1.0.0', false);

    My javascript code:

    <script type="text/javascript">
    jQuery(document).ready(function() {
      jQuery(".content").hide();
      //toggle the componenet with class msg_body
      jQuery(".heading").click(function()
      {
        jQuery(this).next(".content").slideToggle(500);
      });
    });
    </script>

    And I added the following HTML inside the content area of my test page in WordPress. I don't even know if this is the right place but it was the only one I found that let me implement some custom HTML:

    <div class="layer1">
    
    <p class="heading">Header-1 </p>
    <div class="content">Lorem ipsum dolor sit amet, consectetuer adipiscing elit orem ipsum dolor sit amet, consectetuer adipiscing elit</div>
    
    <p class="heading">Header-2</p>
    <div class="content">Lorem ipsum dolor sit amet, consectetuer adipiscing elit orem ipsum dolor sit amet, consectetuer adipiscing elit</div>
    
    <p class="heading">Header-3</p>
    <div class="content">Lorem ipsum dolor sit amet, consectetuer adipiscing elit orem ipsum dolor sit amet, consectetuer adipiscing elit</div>
    
    </div>

    This is the result I want to achieve.

    Thanks for your time!

    December 28, 2015 at 9:00 pm #174993
    James
    Participant

    hi there

    are you using the <script type="text/javascript"> in your jquery, as this won't work

    instead try this

    '

    jQuery(function( $ ){

    $(".content").hide();

    //toggle the componenet with class msg_body
    $(".heading").click(function(){
    $(this).next(".content").slideToggle(500);
    });

    });

    '

    December 28, 2015 at 9:14 pm #174998
    Eric Emanuel
    Member

    I've changed my code to yours, but no success yet... I click on the headers and nothing happens.
    Do you have another idea of what could be wrong?

    December 28, 2015 at 9:32 pm #175002
    James
    Participant

    hey there

    you want a simple expand on click, collapse on click, just like i did here on a client site (scroll to the bottom of the content)

    http://thefacialroom.com.au/services/facials/

    December 28, 2015 at 9:36 pm #175003
    Eric Emanuel
    Member

    Yes, that's exactly what I want!
    I've been struggling with this for hours now, it can't be that hard...

    December 28, 2015 at 9:38 pm #175006
    James
    Participant

    just give me a few minutes and i'll have that for you.

    December 28, 2015 at 10:04 pm #175014
    Eric Emanuel
    Member

    Thanks for your attention, Jamie, I really appreciate it =)

    December 28, 2015 at 10:06 pm #175015
    James
    Participant

    no problem

    be about 5 more minutes...

    December 28, 2015 at 10:40 pm #175022
    James
    Participant

    here you go

    http://jamiemitchelldesign.com.au/create-an-accordion-toggle-in-genesis/

    December 28, 2015 at 10:46 pm #175023
    Eric Emanuel
    Member

    Wow, you've created a whole class just for me? Amazing!
    Thanks a lot, I'll implement it and let you know about the results =)

    December 28, 2015 at 11:02 pm #175025
    Eric Emanuel
    Member

    Worked like a charm! Thank you, my friend, you're the best!
    Your bonus section is also very helpful, I'll study and use this knowledge from now on! =D

    Do you mind if I contact you if I have any more of these newbie questions?

    Thank you very much!

    December 28, 2015 at 11:04 pm #175026
    James
    Participant

    No problem at all

    Your more than welcome to contact me anytime

    if you have any theme issues, try and post on the forum here when you can, that way others can learn as well.

    🙂

    December 28, 2015 at 11:14 pm #175028
    Eric Emanuel
    Member

    I will, thanks again!

  • Author
    Posts
Viewing 13 posts - 1 through 13 (of 13 total)
  • The topic ‘Problems with Genesis + Javascript’ is closed to new replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2023 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble