jquery状态框弹出,过一会就隐藏

标签 jquery

我尝试使用jquery开发一个状态框,所以我有一个按钮,当单击按钮时,状态框会弹出以显示“按钮被单击”之类的消息,并在10秒后消失,但我是不知道该怎么做。 我认为代码可能是这样的:

  <input type="button" id="status" value = "show status box"/>

  <script>
   $("#status").click(function(){
      //not sure what should be inside?
     }
   </script>

最佳答案

类似这样的事情吗?

html

<button id="status">show status box</button>
<div id="statusmessage"></div>

CSS

#statusmessage{
    position:fixed;
    bottom:0;
    padding:0 5px;
    line-height:25px;
    background-color:#eeee99;
    margin-bottom:-25px;
    font-weight:bold;
    left:0;
    right:0;
}

jquery

$("#status").click(function() {
    $('#statusmessage').text('#status button was clicked..').animate({'margin-bottom':0},200);
    setTimeout( function(){
        $('#statusmessage').animate({'margin-bottom':-25},200);
    }, 5*1000);
});

演示地址:http://jsfiddle.net/s3fcy/1/

关于jquery状态框弹出,过一会就隐藏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7828251/

相关文章:

javascript - jqGrid如何向列添加多个复选框

javascript - 如何在Jquery中从ajax成功中识别调用者方法?

javascript - 使用 setTimeout 或动画 css3 时如何使用 Phonegap 和固定的 div?

javascript - jQuery 图像交叉淡入淡出问题

javascript - 如何根据数组更新复选框状态?

jquery - 如何查找由于jquery.live而导致事件的元素

javascript - 在 jQuery 中使用正则表达式检查模式

jquery - 高级 jQuery 过滤 jQuery 数组

javascript - div 全屏(宽度和高度)html/css?

php - 在 JavaScript 中创建 JSON