jQuery+qTip2-选择当前悬停元素
我正在使用qTip2显示表格行的工具提示:jQuery+qTip2-选择当前悬停元素,jquery,jquery-selectors,hover,qtip2,Jquery,Jquery Selectors,Hover,Qtip2,我正在使用qTip2显示表格行的工具提示: @foreach (var item in Model) { <tr id="@(item.ShopListID)"> <td id="name@(item.ShopListFoodID)" class="shoptablename">@Html.DisplayFor(modelItem => item.Name)
@foreach (var item in Model)
{
<tr id="@(item.ShopListID)">
<td id="name@(item.ShopListFoodID)" class="shoptablename">@Html.DisplayFor(modelItem => item.Name)
</td>
<td id="amnt@(item.ShopListFoodID)" class="shoptableamount">@Html.DisplayFor(modelItem => item.Amount)
</td>
</tr>
}
然而,由于我选择使用类,我只获得第一个tr的id,并且无论我将鼠标放在哪一行上,我仍然会获得一些工具提示内容作为第一行。我尝试使用$this来选择id,但没有成功
我需要一个选择器,我可以选择当前的悬停元素
希望能在这里得到一些帮助。。。任何反馈都非常感谢
谢谢……我试着在悬停状态下使用tooptip,这是我的代码,您必须为所有不同的td提供工具提示
<html>
<head>
<title>Test Qtip on Hover</title>
<script src="jquery.1.6.1.min.js"></script>
<script src="jquery.qtip-1.0.0-rc3.min.js"></script>
<style>
.className {
color: red;
}
.classValue {
color: green;
}
</style>
<script type="text/javascript">
$(document).ready(function() {
$('.classValue').each(function() {
$(this).qtip({
content : $(this).text() + "_" + $(this).attr('id')
});
});
});
</script>
</head>
<body>
<table border="1">
<thead>
<th>Name</th>
<th>Value</th>
</thead>
<tbody>
<tr>
<td id="name1" class="className">test1</td>
<td id="value1" class="classValue">test1Val</td>
</tr>
<tr>
<td id="name2" class="className">test2</td>
<td id="value2" class="classValue">test2Val</td>
</tr>
<tr>
<td id="name3" class="className">test3</td>
<td id="value3" class="classValue">test3Val</td>
</tr>
</tbody>
</table>
</body>
</html>
希望这有帮助。hi,$this.attr'id'返回1,2,3。。。对于第一、第二和第三排..嗯,然后尝试使用$this,'.shoptableamount'获取工具iPhone,谢谢,但它无法工作…嗨,非常感谢。我从qTip支持部门得到了一个类似的解决方案,使用.each-too通过每个td循环:谢谢
<html>
<head>
<title>Test Qtip on Hover</title>
<script src="jquery.1.6.1.min.js"></script>
<script src="jquery.qtip-1.0.0-rc3.min.js"></script>
<style>
.className {
color: red;
}
.classValue {
color: green;
}
</style>
<script type="text/javascript">
$(document).ready(function() {
$('.classValue').each(function() {
$(this).qtip({
content : $(this).text() + "_" + $(this).attr('id')
});
});
});
</script>
</head>
<body>
<table border="1">
<thead>
<th>Name</th>
<th>Value</th>
</thead>
<tbody>
<tr>
<td id="name1" class="className">test1</td>
<td id="value1" class="classValue">test1Val</td>
</tr>
<tr>
<td id="name2" class="className">test2</td>
<td id="value2" class="classValue">test2Val</td>
</tr>
<tr>
<td id="name3" class="className">test3</td>
<td id="value3" class="classValue">test3Val</td>
</tr>
</tbody>
</table>
</body>
</html>