我正在尋找通過webgrid呈現的HTML表格中的文本。我想要的文字位於div
內,productID
。我的起始參考點位於同一行,但最後的td
與類span2
。我試圖使用jQuery的closest()方法,但我沒有得到任何返回值。使用jQuery從最近的跨度獲取文本
請參閱下面呈現的HTML的一個部分,我jQuery的功能:
HTML:
<tr>
<td class="span1"><div class="productID">1</div></td>
<td class="span2">Listing</td>
<td class="span2">Full Districtution</td>
<td class="span2">$1,350.00</td>
<td class="span2">2016-01-01</td>
<td class="span2"><div title="This is my brand new title!" data-original-title="" class="priceToolTip">2016-04-30</div></td>
<td><a href="/product/AddOrEditProduct?productID=1">Select</a></td>
</tr>
的jQuery:
$(".priceToolTip").mouseover(function() {
var row = $(this).closest("span1").find(".productID").parent().find(".productID").text();
console.log("Closest row is: " + row);
});