繁体   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