Using hover and click with jQuery UI tabs?

眉间皱痕 提交于 2019-12-11 07:10:17

问题


I am using the following code for my jQuery UI tabs:

$('#tabs').tabs({
    fx: { opacity: 'toggle', duration: 400 }}).tabs('rotate', 1000);
$("#tabs").hover(function() {
    $("#tabs").tabs("rotate",0);
},

function() {
    $("#tabs").tabs("rotate",1000);
});

$("#tabs").click(function() {
    $("#tabs").tabs('rotate', 0);
});

The tabs are rotating properly and the rotation stop when hovering with the mouse. However, the 'hover' function is also overriding the 'click' function. How can I achieve a pause when hovering, and a complete stop to the rotation on click?


回答1:


Try this

$('#tabs').tabs({ 
    fx: { opacity: 'toggle', duration: 400 }
}).tabs('rotate', 1000);

$("#tabs").hover(
    function() {
        $("#tabs").stop();
    },
    function() {
        $("#tabs").tabs("rotate",1000);
    }
);

$("#tabs").click(
    function() {
        $("#tabs").stop(true);
    }
);



回答2:


just a week ago i looked for the same issue. Now i created an extesion: Pause on Hover for jQuery UI Tabs Rotate



来源:https://stackoverflow.com/questions/7234541/using-hover-and-click-with-jquery-ui-tabs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!