如何在javascript中显示鼠标悬停列表?

时间:2017-02-10 05:52:11

标签: javascript

嗨我正试图在鼠标悬停时显示列表如果长度> 0则我显示count.On鼠标在列表上我想显示list.But在我的情况下列表总是在长度为> o时显示。如何仅在鼠标悬停时显示列表? 我究竟想要的是

 if (feature.attributes.hasOwnProperty("ExceptionType")) {

                    var exceptionType = 'x,y';
                    if (exceptionType)
                    { var activeExceptions = exceptionType.split(','); }
                    else
                    { var activeExceptions = []; }

                    var item, items = [];
                    for (var i = 0; i < activeExceptions.length; i++) {
                        item = {};
                        item.activeexception = activeExceptions[i];
                        items.push(item);
                    }

                    var main = $("<ul>");
                    var str = "<ul>";
                    for (var i = 0; i < items.length; i++) {
                        str += "<li>" + items[i].activeexception + "</li>";
                    }
                    $('[rel="tooltip"]').tooltip();

                    main.html(str);
                    if (activeExceptions.length == 0) {
                        feature.attributes.Hoverlist = ".showme{display: none}";
                        feature.attributes.ShowExceptionType = "display:none";

                    }

                    else 

                        feature.attributes.Hoverlist = ".showhim:hover .showme{ display : block;}";
                        feature.attributes.ShowExceptionType = "display:block";
                        feature.attributes.HoverContent = str;
                        feature.attributes.ExceptionCount = activeExceptions.length;


                }

  "description": "<div class='showhim' style='{ShowExceptionType}' ng-mouseover='alert('hi');'>{ExceptionCount}<div class='showme' style='{Hoverlist}'>{HoverContent}</div></div>",

1 个答案:

答案 0 :(得分:0)

问题是我需要在弹出窗口加载时将工具提示置于顶部。

$('[rel="tooltip"]').tooltip();