Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/84.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery qTip2循环工作,但数据信息不变_Jquery_Qtip2 - Fatal编程技术网

Jquery qTip2循环工作,但数据信息不变

Jquery qTip2循环工作,但数据信息不变,jquery,qtip2,Jquery,Qtip2,几分钟前,我创建了一个类似的主题,你可以在这里看到: 这就解决了 但我现在的问题是另一个 这里有一个例子 如果将鼠标悬停在链接上,它们都具有相同的标题和相同的文本,这是不正确的。 例如,如果我使用console.log(title)调试title,则返回的值对于循环中的每个项目都是正确的 有什么不对劲?谢谢。我送你来这里 为了达到适当的要求,在布局上做了很多修改 HTML代码: CSS代码: 如果您有任何其他问题,请在下面添加评论 尊敬D.您的老JS: $('a').each(function

几分钟前,我创建了一个类似的主题,你可以在这里看到: 这就解决了

但我现在的问题是另一个

这里有一个例子

如果将鼠标悬停在链接上,它们都具有相同的
标题
和相同的
文本
,这是不正确的。 例如,如果我使用
console.log(title)
调试
title
,则返回的值对于循环中的每个项目都是正确的

有什么不对劲?谢谢。

我送你来这里

为了达到适当的要求,在布局上做了很多修改

HTML代码:

CSS代码:

如果您有任何其他问题,请在下面添加评论

尊敬D.

您的老JS:

$('a').each(function () {
    if ($(this).hasClass('qTip')) {
        var value = $(this).next('div')[0].innerHTML;
        var title = $(this).attr('title');
        $('.qTip').qtip({
            style: {
                classes: 'qtip-bootstrap'
            },
            content: {
                title: title,
                //text: value // The problem is here (on the `text` option)
                text: value
            }
        });
    }
});
工作JS:

$('a').each(function () {
    if ($(this).hasClass('qTip')) {
        var value = $(this).next('div')[0].innerHTML;
        var title = $(this).attr('title');
        $(this).qtip({
            style: {
                classes: 'qtip-bootstrap'
            },
            content: {
                title: title,
                //text: value // The problem is here (on the `text` option)
                text: value
            }
        });
    }
});
第五行是需要更改的
$('.qTip')
选择该类中的每个元素,并为它们提供所有相同的值。您需要调用
$(this)
上的
qtip
,即当前的

.hide {
    display: none;
}
$('a').each(function () {
    if ($(this).hasClass('qTip')) {
        var value = $(this).next('div')[0].innerHTML;
        var title = $(this).attr('title');
        $('.qTip').qtip({
            style: {
                classes: 'qtip-bootstrap'
            },
            content: {
                title: title,
                //text: value // The problem is here (on the `text` option)
                text: value
            }
        });
    }
});
$('a').each(function () {
    if ($(this).hasClass('qTip')) {
        var value = $(this).next('div')[0].innerHTML;
        var title = $(this).attr('title');
        $(this).qtip({
            style: {
                classes: 'qtip-bootstrap'
            },
            content: {
                title: title,
                //text: value // The problem is here (on the `text` option)
                text: value
            }
        });
    }
});