Results 1 to 2 of 2

Thread: Jquery Animate Width

  1. #1
    Join Date
    Mar 2010
    Location
    Florida
    Posts
    512
    Thanks
    9
    Thanked 61 Times in 59 Posts

    Default Jquery Animate Width

    So I am currently have a problem with jquery's animate. I am trying to anime an '<ul> <li>' it works with
    Code:
    $(this).next('li').animate({width:'toggle'},300)
    but doesn't work with
    Code:
    $(this).next('li').animate({width:'300px'},300)
    here is the a sample code:

    HTML Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Game Selection</title>
    <style>
    * { margin:0 auto; padding:0;}
    body { background-color:#CCCCCC;}
    
    #group2 { width: 90%; margin-top:5px;}
    #group2>li { list-style:none; float:left; border:1px solid black; height:300px; border-left:none;}
    
    .spacer { clear:both;}
    </style>
    
    <script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
    <script>
    
    $(function(){
    	
    	group2()
    	
    })
    function group2(){
    	
    	$('#group2>li').first().css('border-left','1px solid black')
    	
    	$('#group2>li:odd').css('display','none').css('width','300px')
    	$('#group2>li:even').css('cursor','pointer')
    	$('#group2>li').eq(1).show(300)
    }
    
    $(document).on('click','#group2>li:even',function(){
    	$(this).next('li').show(300)
    	$(this).prevAll('li:even').hide(300)
    	$(this).next('li').nextAll('li:odd').hide(300)
    })
    
    </script>
    </head>
    <body>
    
    <div><ul id="group2">
    	<li class="bce_show">X</li><li>Something</li>
    	<li class="bce_show">Y</li><li>Something</li>
            <li class="bce_show">Z</li><li>Something</li>
    </ul><div class="spacer"></div></div>
    
    </body>
    </html>
    *NOTE: Just realized i can use even and odd instead of the for/if statement xD
    Ill fix that later
    Last edited by Deadweight; 02-28-2014 at 03:20 AM.
    -DW [Deadweight]
    Resolving your thread: First Post: => EDIT => Lower right: => GO ADVANCED => Top Advance Editor drop down: => PREFIX:Resolved

  2. #2
    Join Date
    Mar 2010
    Location
    Florida
    Posts
    512
    Thanks
    9
    Thanked 61 Times in 59 Posts

    Default

    Nevermind i fixed it myself.
    -DW [Deadweight]
    Resolving your thread: First Post: => EDIT => Lower right: => GO ADVANCED => Top Advance Editor drop down: => PREFIX:Resolved

Similar Threads

  1. Resolved Better way to program this - Animate width/height
    By keyboard in forum JavaScript
    Replies: 4
    Last Post: 11-22-2012, 08:11 AM
  2. jquery .animate() function
    By creative creator in forum JavaScript
    Replies: 1
    Last Post: 11-29-2010, 08:51 AM
  3. Replies: 4
    Last Post: 05-30-2010, 02:30 PM
  4. animate background images
    By dothemath in forum Looking for such a script or service
    Replies: 7
    Last Post: 07-21-2009, 04:39 PM
  5. Replies: 2
    Last Post: 05-12-2009, 11:42 AM

Bookmarks

Posting Permissions

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