Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Page 1 of 3 1 2 3 LastLast
Results 1 to 10 of 23
  1. #1
    Member
    Join Date
    Aug 2013
    Posts
    89
    Member #
    37057

    jQuery add to another class ?

    How do I apply the same effect that is happening with the class .about to the class .contact ?
    code

  2.  

  3. #2
    Senior Member Ronald Roe's Avatar
    Join Date
    Mar 2011
    Location
    Oklahoma City
    Posts
    3,141
    Member #
    27197
    Liked
    959 times
    Code:
    $('.about, .contact')
    Ron Roe
    Web Developer
    "If every app were designed using the same design template, oh wait...Bootstrap."

  4. #3
    Senior Member DC Web Design's Avatar
    Join Date
    Jan 2014
    Location
    Washington, DC
    Posts
    128
    Member #
    38178
    Liked
    37 times
    Like Ronald said, with jQuery, it's pretty much the same way you would target multiple selectors with CSS: separating with a comma.

  5. #4
    Member
    Join Date
    Aug 2013
    Posts
    89
    Member #
    37057
    Thanks, I can't get both classes .contact & .about from opening and closing simultaneously. As well, the class .contact won't collapse as the the .about class does.

  6. #5
    Senior Member Ronald Roe's Avatar
    Join Date
    Mar 2011
    Location
    Oklahoma City
    Posts
    3,141
    Member #
    27197
    Liked
    959 times
    That's because you're telling it to run the script on both no matter which is clicked. You'll need to use the "this" keyword. Here, I updated your fiddle: Edit fiddle - JSFiddle

    P.S. You may want to ween yourself off the toggle-event class. It was deprecated several versions ago.
    Last edited by Ronald Roe; Jan 20th, 2014 at 11:26 AM.
    Ron Roe
    Web Developer
    "If every app were designed using the same design template, oh wait...Bootstrap."

  7. #6
    Member
    Join Date
    Aug 2013
    Posts
    89
    Member #
    37057
    Ah the 'this' word, my knowledge of the jQuery framework is rusty When the class .about is collapsed the class .middle would expand ?

    I have in my head to getElementById("") jQuery works differently

  8. #7
    Senior Member Ronald Roe's Avatar
    Join Date
    Mar 2011
    Location
    Oklahoma City
    Posts
    3,141
    Member #
    27197
    Liked
    959 times
    Quote Originally Posted by Shang Tsung View Post
    Ah the 'this' word, my knowledge of the jQuery framework is rusty
    "This" is part of the javascript core, not jQuery.

    Quote Originally Posted by Shang Tsung View Post
    When the class .about is collapsed the class .middle would expand ?
    Not sure what you mean.
    Ron Roe
    Web Developer
    "If every app were designed using the same design template, oh wait...Bootstrap."

  9. #8
    Member
    Join Date
    Aug 2013
    Posts
    89
    Member #
    37057
    When you click the .contact & .about class buttons (or black bars, whichever you prefer to refer to them as), the section=middle I want to expand only when either or both of .contact & .class are collapsed. I hope that made sense, if not just tell me

  10. #9
    Member
    Join Date
    Aug 2013
    Posts
    89
    Member #
    37057
    There isn't a 'expand' command for jQuery. When the classes .about & .contact contract, I want the section=middle to expand.
    Ronald in the jQuery code that was in post #5, that contains a anonymous function, correct ?

  11. #10
    Senior Member Ronald Roe's Avatar
    Join Date
    Mar 2011
    Location
    Oklahoma City
    Posts
    3,141
    Member #
    27197
    Liked
    959 times
    If I'm understanding what you want, you'll need to select the section
    Code:
    $('.middle')
    and then usethe .css() method to expand it under the right conditions. You'll need to add a condition to test whether it's already expanded and then expand if necessary. Try to work it out, and if you can't get it, I'll help later. Unfortunately, my computer at my day job only has IE8 and stiff penalty for trying to install software, so I don't have JSFiddle access right now.
    Ron Roe
    Web Developer
    "If every app were designed using the same design template, oh wait...Bootstrap."


Page 1 of 3 1 2 3 LastLast

Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 08:46 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com