开发者

jQuery animate won't slide width, but will toggle

开发者 https://www.devze.com 2023-03-09 03:40 出处:网络
I am trying to get jQuery to animate with slide rather than toggle. I have these files included in my HTML <head>:

I am trying to get jQuery to animate with slide rather than toggle. I have these files included in my HTML <head>:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script> 
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.13/jquery-ui.min.js"></script>

jQuery:

// $item is a list gathered as $('#gallery ul li') and all output to console as should
// $prev will be used to get current li width, but not to worry about for now.
$.fn.slider = function($item,$prev){
        $item.each(function(i){
            $(this).animate({width:'slide',le开发者_开发问答ft:'-= 500'});
        });
    };

What I don't understand is if I change the animate width from slide to toggle, it will work, but with the slide, nothing happens. I tested at jsfiddle, and the slide works there. What's the deal? What am I missing that jsfiddle has?

Edit: Here is the fiddle: http://jsfiddle.net/robx/ZvKUW/1/


From http://api.jquery.com/animate/

In addition to numeric values, each property can take the strings 'show', 'hide', and 'toggle'. These shortcuts allow for custom hiding and showing animations that take into account the display type of the element.

Note that 'slide' isn't mentioned, therefore it's ignored.

0

精彩评论

暂无评论...
验证码 换一张
取 消