开发者

how to make an item slideUp automatically after specific time in jquery

i have made an rss reader which takes feeds from a db and shows the title articles.The following code does this: When a user clicks the titles(a.title) of the articles the content of the articles slideDown and appears.The content is in hidden class with the name content.When the user clicks the title again the content of the article slidesUp and dissapears.

$("a.title").live("click", function(){
        $(this).next("div.content").slideToggle();
});

How can i modify this part of the code in order in the first click the content of the feed to slidedown.In the second click of the title of the feed the content to slideUp?untill now the same functionality as i described. But if the user only clck the feed once in order to appear the content of the feed and leave the feed with its content shown, after some time for example 2 minutes the content of the feed to slideUp automatically if no mouse movement notified.I tried to make that with setInterval funct开发者_JAVA百科ion and mousemove but i couldn;t make it.Any ideas???Thanks in advance....


Try this:

$("a.title").live("click", function(){
       setTimeout("alert('3 seconds.');",3000);
        $(this).next("div.content").slideToggle();
});

As of jQuery 1.4 you can use delay()

$("a.title").live("click", function(){
        $(this).next("div.content").delay(3000).slideToggle();
});
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜