dxTooltip 在 IE 中不工作,在 Chrome 中工作

dxTooltip not working in IE, working in Chrome

我有一个 dxChart:

            var chart = $("#chartContainer4").dxChart();

其中我使用的是图例矩形:

            var PayerLegendBoxes = $("#chartContainer4 .dxc-legend g rect");

并使用 dxTooltip 在鼠标悬停时显示。

            PayerLegendBoxes.each(function () {



                var nextElementHTML = this.nextSibling.innerHTML;

                var currElementTip = nextElementHTML + "tip";

                var currElement = this;



                var title = chart.append("<span style='display:none;' id=" + currElementTip + ">" + nextElementHTML + "</span>");



                var tooltipSimple = $("#" + currElementTip).dxTooltip({

                    target: currElement,

                }).dxTooltip("instance");



                $(currElement).unbind().hover(function () {

                    tooltipSimple.toggle()

                });



            });

这在 Chrome 中工作正常,但在 IE 中不工作。

跨浏览器功能是否存在错误?

看起来问题出在这一行:

var nextElementHTML = this.nextSibling.innerHTML;

nextSibling.innerHTML returns undefined 在 IE 中。所以,我建议你使用这样的东西:

// jQuery provides a "cross-browser" way here
var nextElementHTML = $(this).next().text();

这一行还有一个更正:

var currElementTip = nextElementHTML + "tip";

nextElementHTML 有时可以包含一个白色的 space 符号。所以,你应该清理它:

var currElementTip = (nextElementHTML + "tip").replace(/\s/g, "_");

更新的样本在这里 - http://jsfiddle.net/5y8f4zt0/