Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 10 of 10
  1. #1
    Regular Coder
    Join Date
    Jun 2006
    Location
    UK
    Posts
    892
    Thanks
    301
    Thanked 2 Times in 2 Posts

    Question jQuery: Slide Left to Right

    Hi,

    I know how to Slide a DIV from top to bottom and vice-versa. The following code shows how to do it:

    Code:
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script>
    <script>
    $().ready(function(){
    				   $("#clicky").click(function(){
    					$("#slide").slideToggle("slow");						   
    											   });
    				   
    				   });
    </script>
    
    <input name="" type="button" value="Click me" id="clicky"/>
    <div id="slide">
    <h1>Hello World!</h1>
    </div>

    Question: Is there anyway I can slide a DIV from left to right and vice-versa?

    Please help.


    Thanx in advance

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,730
    Thanks
    202
    Thanked 2,507 Times in 2,485 Posts
    Have a look at:-

    http://www.webinventif.fr/wslide-plugin/
    and demos at http://www.webinventif.fr/wp-content...t-wslide-2.htm

    Although the site is in French.



    Quizmaster: Who was President of Yugoslavia until 2003?
    Contestant: Angela Merkel.

  • #3
    Senior Coder rangana's Avatar
    Join Date
    Feb 2008
    Location
    Cebu City, Philippines
    Posts
    1,752
    Thanks
    65
    Thanked 372 Times in 365 Posts
    You can take advantage of the animate function:
    Code:
    $(function(){
    	$("#clicky").click(function(){
    		$("#slide").animate({marginLeft:'500px'},'slow');				   
    	});			   
    });
    Hope that helps.
    Learn how to javascript at 02geek

    The more you learn, the more you'll realize there's much more to learn
    Ray.ph

  • #4
    Regular Coder
    Join Date
    Jun 2006
    Location
    UK
    Posts
    892
    Thanks
    301
    Thanked 2 Times in 2 Posts
    Quote Originally Posted by rangana View Post
    You can take advantage of the animate function:
    Code:
    $(function(){
    	$("#clicky").click(function(){
    		$("#slide").animate({marginLeft:'500px'},'slow');				   
    	});			   
    });
    Hope that helps.
    Two problems:

    1) It does not toggle.

    2) Its just moving, not sliding (show/hide)

  • #5
    Senior Coder rangana's Avatar
    Join Date
    Feb 2008
    Location
    Cebu City, Philippines
    Posts
    1,752
    Thanks
    65
    Thanked 372 Times in 365 Posts
    Code:
    $("#slide").animate({width:'toggle'},2000);
    Learn how to javascript at 02geek

    The more you learn, the more you'll realize there's much more to learn
    Ray.ph

  • #6
    Regular Coder
    Join Date
    Jun 2006
    Location
    UK
    Posts
    892
    Thanks
    301
    Thanked 2 Times in 2 Posts
    Quote Originally Posted by rangana View Post
    Code:
    $("#slide").animate({width:'toggle'},2000);
    Happens only one time

    Does not toggle

  • #7
    Senior Coder rangana's Avatar
    Join Date
    Feb 2008
    Location
    Cebu City, Philippines
    Posts
    1,752
    Thanks
    65
    Thanked 372 Times in 365 Posts
    Are you certain? It show/hides the element basing on the width. Works fine at my end.
    Learn how to javascript at 02geek

    The more you learn, the more you'll realize there's much more to learn
    Ray.ph

  • #8
    Regular Coder
    Join Date
    Jun 2006
    Location
    UK
    Posts
    892
    Thanks
    301
    Thanked 2 Times in 2 Posts
    Plz post your whole code.

    Thanx

  • #9
    Regular Coder
    Join Date
    Jun 2006
    Location
    UK
    Posts
    892
    Thanks
    301
    Thanked 2 Times in 2 Posts
    Quote Originally Posted by rangana View Post
    Are you certain? It show/hides the element basing on the width. Works fine at my end.
    Seems to be working now. But It starts sliding after 1.5 seconds of clicking on the button. Any particular reasons for this?

  • #10
    New to the CF scene
    Join Date
    Apr 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Macintosh

    Just Decrease the value from 2000 to 200... you will feel the difference. You can adjust accordingly to get slow or fast effect


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •