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.

Results 1 to 7 of 7

Thread: Jquery Help

  1. #1
    Member
    Join Date
    Nov 2012
    Location
    Huddersfield, West Yorkshire
    Posts
    68
    Member #
    33961
    Liked
    5 times
    Hello Guys,

    Using this fucntion:

    $('#switchbutton2').click(function(){

    $('#switch1,#switch3,#switch4,#switch5').hide(func tion(){

    $('#switch2').show();

    });
    });

    Simply shows and hides the content. Pretty simple.

    Is there anyway that i could set a variable at the top of the script so i could change animation and speed of the animation for all the functions above (remember there will be more than one switching snippet).

    In other words, could i add a function name to the hide "function" and set up some code to gloablly change the animation and speed. Like a plugin.

    Hope this is enough explanation.

  2.  

  3. #2
    Member Eric Mintz's Avatar
    Join Date
    Mar 2012
    Location
    Atlanta, GA
    Posts
    48
    Member #
    31243
    Liked
    7 times
    One way would be to have a speed variable:

    var animationSpeed = 1000;

    Then change:
    $('#switch1,#switch3,#switch4,#switch5').hide(func tion(){
    to:
    $('#switch1,#switch3,#switch4,#switch5').hide(anim ationSpeed,function(){

    And if you want, change:
    $('#switch2').show();
    to:
    $('#switch2').show(animationSpeed);

  4. #3
    Member
    Join Date
    Nov 2012
    Location
    Huddersfield, West Yorkshire
    Posts
    68
    Member #
    33961
    Liked
    5 times
    Excellent. Thankyou sir.

  5. #4
    Senior Member Andrew Yurlov's Avatar
    Join Date
    Apr 2011
    Location
    Portland, OR
    Posts
    1,306
    Member #
    27566
    Liked
    181 times
    So your trying to hide/show something like a div onClick? Like a toggle switch? If that's the case there is a simpler way to do that.

    You will need a link to serve as your toggle switch
    Code:
    <a href="javascript:toggleDiv('ThisIsTheDiv');">
    <div id="ThisIsTheDiv"></div>
    </a>
    and of course the jquery

    Code:
    function toggleDiv(divId) {
      $("#"+divId).slideToggle('fast');
    }
    This this what you were looking for?
    labforone/Ben likes this.
    Artificial intelligence is nothing compared to natural stupidity -Someone

    Design is a funny word. Some people think design means how it looks.
    But of course, if you dig deeper, itís really how it works.
    -Steve Jobs



  6. #5
    Member
    Join Date
    Nov 2012
    Location
    Huddersfield, West Yorkshire
    Posts
    68
    Member #
    33961
    Liked
    5 times
    Brilliant!

  7. #6
    Senior Member Andrew Yurlov's Avatar
    Join Date
    Apr 2011
    Location
    Portland, OR
    Posts
    1,306
    Member #
    27566
    Liked
    181 times
    Quote Originally Posted by labforone/Ben, post: 248444
    Brilliant!
    I'm learning jQuery myself right now. Glad to help
    labforone/Ben likes this.
    Artificial intelligence is nothing compared to natural stupidity -Someone

    Design is a funny word. Some people think design means how it looks.
    But of course, if you dig deeper, itís really how it works.
    -Steve Jobs



  8. #7
    Member
    Join Date
    Nov 2012
    Location
    Huddersfield, West Yorkshire
    Posts
    68
    Member #
    33961
    Liked
    5 times
    Since I have been learning ive used it in almost all my projects! One of the best things i've ever done!


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 05:00 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com