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
}
});
}
});