簡體   English   中英

jQuery的工具提示

[英]Jquery for Tooltip

我將以下代碼用於Click事件的工具提示顯示

HTML組件:

 <a href="#" class="tooltip" data-description="Test tooltip">Test</a><br>

jQuery的:

$(document).on("click", ".tooltip", function() {
    $(this).tooltip(
        { 
            items: ".tooltip", 
            content: function(){
                return $(this).data('description');
            }, 
            close: function( event, ui ) {
                var me = this;
                ui.tooltip.hover(
                    function () {
                        $(this).stop(true).fadeTo(400, 1); 
                    },
                    function () {
                        $(this).fadeOut("400", function(){
                            $(this).remove();
                        });
                    }
                );
                ui.tooltip.on("remove", function(){
                    $(me).tooltip("destroy");
                });
          }
        }
    ); // this is the line i'm getting "Expected Identifier, string or number". 
    $(this).tooltip("open");
});

我正在使用jquery 1.9.1.js和jquery-ui.1.9.2.js。 但是我得到“期望的標識符,字符串或數字”。

編輯:錯誤已解決,但我仍未獲得有關單擊事件的工具提示。
有人可以告訴我我哪里出問題了嗎?

該Codepen: http ://codepen.io/anon/pen/EjVBOW似乎對我來說適合您的代碼以及最新的jQuery和jQuery UI。 它為您解決了嗎?

$(document).on("click", ".tooltip", function() {
  $(this).tooltip({
    items: ".tooltip",
    content: function() {
      return $(this).data('description');
    },
    close: function(event, ui) {
      var me = this;
      ui.tooltip.hover(
        function() {
          $(this).stop(true).fadeTo(400, 1);
        },
        function() {
          $(this).fadeOut("400", function() {
            $(this).remove();
          });
        }
      );
      ui.tooltip.on("remove", function() {
        $(me).tooltip("destroy");
      });
    }
  }); // this is the line i'm getting "Expected Identifier, string or number". 
  $(this).tooltip("open");
});

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM