English 中文(简体)
简讯 时间范围问题
原标题:JavaScript setTimeout scope issue
var toogleDelay = 500;
var closeTimeout = null;

$(">ul>li", $nav).hover(function () {
    var $this = $(this);
    if(closeTimeout) {
        clearTimeout(closeTimeout);
    }
    var openMenuCallback = function() {
        $this.addClass("hover");
    };
    window.setTimeout(openMenuCallback, toogleDelay);
}, function () {
    var $this = $(this);
    var closeMenuCallback = function() {
        $this.removeClass("hover");
    };
    closeTimeout = window.setTimeout(closeMenuCallback, toogleDelay);
});

我利用这一幻灯来开张并关闭多管齐下,我希望菜单能够破灭,有0.5个拖延。 我也明确提到支离破碎的部分功能,这样,如果有些人(显然)离开了菜园,再在0.5秒内进入菜园,则菜单不会关闭。 所有这一切都很出色,但现在我有问题,因为现在不止一次下降,如果我把use从头直接移至第二滴,而且现在我两处都开放了退学,那么,让步的结束时间就已经结束。 我必须怎样重写这部法典,以便每 drop倒都能够保持自己的密切关系。 与此同时,我仍然能够清除over余部分功能的停用时间。

thx sub

最佳回答

您可在<条码>数据中存储时间。 类似于

var $this = $(this);
var closeMenuCallback = function() {
    $this.removeClass("hover");
    $this.removeData("timerid");
};
var closeTimeout = window.setTimeout(closeMenuCallback, toogleDelay);
$this.data("timerid", closeTimeout);

之后检查

var $this = $(this);
var closeTimeout = $this.data("timerid");
if(closeTimeout) {
    clearTimeout(closeTimeout);
    $this.removeData("timerid");
}
问题回答

I know this isn t part of the question but I like the CSS approach to this.

http://web Designer Wall.com/tutorials/cs3-dropdown-menu”rel=“nofollow> http://web Designer Wall.com/tutorials/cs3-dropdown-menu

there are a number of examples for this. some multilevel some not.





相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签