当用户将鼠标悬停在我的 helpicon3 图标上以及我网页上的三个输入文本项上时,我正在尝试使用 qTip2 显示帮助文本。
我创建的每个项目,我都预先分配了当用户将鼠标悬停在该输入项目的帮助图标上时要为该项目显示的工具提示文本,即:
<span class="itemToolTip" foritem="P35_TEST">This is some help text from the help section of the item.</span>
<span class="itemToolTip" foritem="P35_A1">This is some help text for A1 item</span>
<span class="itemToolTip" foritem="P35_B1">This is some help text for B1 item</span>
o 基于此,当我使用 qTip2 将鼠标悬停在“P35_A1”帮助图标上时,我会看到工具提示文本“这是 A1 项目的一些帮助文本”。这同样适用于其他两项。
我从页面的视图源中提取的代码如下所示:
<label for="P35_TEST"></label>
<td colspan="1" rowspan="1" align="left"><input type="text" name="p_t04" size="30" maxlength="2000" value="" id="P35_TEST" /><td colspan="1" rowspan="1" align="top"><div id="helpicon"><img src="helpIcon3" border="0" alt="" style="cursor:normal" /></div></td>
<label for="P35_A1"></label>
<td colspan="1" rowspan="1" align="left"><input type="text" name="p_t05" size="30" maxlength="2000" value="" id="P35_A1" /><td colspan="1" rowspan="1" align="top"><div id="helpicon"><img src="helpIcon3" border="0" alt="" style="cursor:normal" /></div></td>
<label for="P35_B1"></label>
<td colspan="1" rowspan="1" align="left"><input type="text" name="p_t06" size="30" maxlength="2000" value="" id="P35_B1" /><td colspan="1" rowspan="1" align="top"><div id="helpicon"><img src="helpIcon3" border="0" alt="" style="cursor:normal" /></div></td>
现在,我拥有但不工作的带有 qTip2 的 jQuery 代码如下。
显然,这是我遇到问题的上下文文本部分,因为我试图用 .each 函数做的是匹配我悬停的项目帮助图标与 itemtooltip foritem help 上面出现在我的工具提示中。
$(document).ready(function() {
$('span.itemToolTip').each(function(i){
$('#helpicon').qtip({
content: {
text: $('label[for="' + $(this).attr('foritem') + '"]').attr('title',$(this).html())
},
style: {
classes: 'ui-tooltip-dark ui-tooltip-rounded',
height: 5,
width: 100
},
position: {
my: 'bottom center',
at: 'top center',
viewport: $(window)
}
});
});
});
同样,如果我使用 qTip2 将鼠标悬停在“P35_TEST”帮助图标上,我会看到工具提示文本“这是来自项目帮助部分的一些帮助文本”。
我目前正在尝试将标签帮助图标与实际的工具提示文本匹配。除此之外,还有其他方法也使用 qTip2 吗?