English 中文(简体)
如何使这个JQuery.animation()真正具有动画效果。
原标题:How to make this JQuery .animation() actually animate.

我无法使用这个下拉菜单来缓慢地设置动画,甚至做任何事情。

$(document).ready(function () {
    $( #menu > li ).hover(function () { $( ul:first , this).show(); },
                           function () { $( ul:first , this).hide(); }
    );

    $( #menu li li ).hover(function () {
        $( ul:first , this).each(function () {
            var p = $(this).parent();
            $(this).animate( top , p.position().top)
                   .animate( left , p.position().left + p.width())
                   .show();
        });},
        function () { $( ul:first , this).hide(); }
    );
});
最佳回答

jQuery的<code>animate()</code>需要一个CSS属性的对象/“映射”。第二个参数以毫秒为单位定义动画的持续时间。

您的示例看起来像这样(-在2000ms内设置顶部左侧属性的动画):

$(this)
    .show()
    .stop() // see below
    .animate({
         top : p.position().top,
         left : p.position().left + p.width()
    }, 2000);

如果您从悬停处理程序中调用动画,您可能需要同时查看stop()

提示:docs是解决此类问题的简单方法。

问题回答

暂无回答




相关问题
PHP Combo Box AJAX Refresh

I have a PHP page that currently has 4 years of team positions in columns on the page. The client wants to select the players in positions and have first, second and thrid choices. Currently the page ...

jquery + ajax + json + fill dropdown list not working

I m pretty sure i am almost there....but i cannot figure out how to iterate through json objects and fill a dropdown list. Here is the js code: My JSON data returned:{"name":"County1","name":"County1"...

Gridviews and DropdownLists

Is it possible to change the data source of a dropdown list in a gridview from another dropdown list selected index changed method in the same gridview? for example I have a dropdown that needs to ...

Adding a new value to the drop down list box

I have a drop down list box which has one of the values to be others. I want to move these value to the last. Please help me with this. The code i am using is as follows ddlAssetsCountryOthersone....

Show hide div using codebehind

I have a DropDownList for which I am trying to show a div OnSelectedIndexChanged but it says OBJECT REQUIRED. I am binding the DataList in that div: aspx: <asp:DropDownList runat="server" ID="...

Why might dropdownlist.SelectedIndex = value fail?

I have a dropdown list that I am binding to a datatable. Here is the code I am using to do it: ddlBuildAddr.DataSource = buildings ddlBuildAddr.DataTextField = "buildingName" ddlBuildAddr....

热门标签