1

(编辑)当前行为是悬停时不显示工具提示。不是默认的 html 标题或 jquery 工具提示(/edit)

我在网页上有一个日历。当一天有一个事件并且您将鼠标悬停在它上面时,会显示 html 标题属性,其中包含用逗号分隔的事件名称。当一天有 20 个事件时,这将开始看起来很难看,所以我想使用 jQuery 以不同的方式显示。这是我用于显示工具提示的代码(我在使用 $ for jQuery 时遇到了问题,因为我不了解页面上其他 jQuery 脚本之间的冲突内容,并且全部输入似乎只是工作):

jQuery(function(){
        var tip = jQuery("#tip");

        //on hover of links with a class of "eventful"
        jQuery(".eventful a").hover(function(e){

            //pull the title attribute into variable "tip"
            tip.text(jQuery(this).attr("title"));

            //make the default title blank
            jQuery(this).attr("title", "");

            //place the new title with css
            tip.css("top",(e.pageY+5)+"px")
                .css("left",(e.pageX+5)+"px")
                .fadeIn("slow");

        }, function() {
                //on mouse out remove
                jQuery("#tip").fadeOut("fast");

                //replace the default title
                jQuery(this).attr("title", tip.html());
        });
    });

这不起作用,所以我不确定我在那里做错了什么。但是在显示工具提示后,我需要更改多个逗号分隔事件的显示方式,最好更改为无序列表。我在下面有这个片段,它可能会将项目分隔成一个数组,也可能不会,在每个逗号处断开字符串:

var titleArray = $(".eventful").attr("title").split(",");

如果这确实有效,我不确定如何将其合并,并将其放入 ul。非常感谢您对此的帮助!

4

1 回答 1

0

提示 div 应该有position:absolute样式并且它的 z-index 应该大于页面中的其他元素。添加jQuery("#tip").css('z-index',somehighvalue)

于 2011-04-08T17:39:28.187 回答