jquery移动弹出消息在几秒钟后消失

时间:2014-03-26 19:59:32

标签: javascript jquery jquery-mobile

在母版页上我有

$(document).bind("pageinit", function () {               
     $.mobile.loading('hide');                
});

我正在渲染这样的弹出消息

$.mobile.loading('show', { theme: "a", text: "My Text...", textonly: true, textVisible: true });

我只需要让这条消息在2秒后消失,现在它永远保持在最佳状态。

1 个答案:

答案 0 :(得分:1)

在你想要的whateveer间隔之后,只需使用超时来执行代码,

例如

 //display loading message
$.mobile.loading('show', 
   { theme: "a", text: "My Text..."
      , textonly: true, textVisible: true });

   //execute code after 2 seconds
  setTimeout(function () {

    $.mobile.loading('hide');
  },2000);

这是jsbin

的链接