首頁  >  文章  >  web前端  >  jQuery實作的簡單提示訊息外掛_jquery

jQuery實作的簡單提示訊息外掛_jquery

WBOY
WBOY原創
2016-05-16 15:27:161164瀏覽

本文實例講述了jQuery實作的簡單提示資訊外掛程式。分享給大家參考,具體如下:

jQuery程式碼如下:

(function ($) {
  $.fn.Tips = function (options) {
    var defaults = {
      html: "",
      times: 3000
    }
    _this_ = $("#tips");
    _this_.html(options.html);
    _this_.show();
    setTimeout(function () { _this_.hide() }, options.times);
  };
})(jQuery);

css樣式如下:

.tips
{
  height: 20px;
  background-color: Green;
  padding: 5px 20px;
  color: White;
  display: none;
  margin-left: 50px;
}

使用方法:

<span class="tips" style="display:none" id="tips"><span>
<script>
$("#aa").Tips({html:"提示信息的内容",times:4000})
</script>

希望本文所述對大家jQuery程式設計有所幫助。

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn