如何使用 Java Script 在最接近的标签中找到类?需要在 . 例子如下:
<tr>
<td class="customer">
@Html.DisplayFor(modelItem => item.Cust)
</td>
<td>
<select id="decisionList">
<option value="0" selected></option>
<option value="1">None</option>
</select>
</td>
</tr>
我在 JS 中试过这个:
document.querySelectorAll("#decisionList").forEach(elem => elem.addEventListener("change", function () {
var selectedOptionIndex = this.options[this.selectedIndex].index; //this works perfectly
var invoiceDateText = this.closest('tr').find('customer').textContent; //this doesn't work
// ...some other code
幕布斯7119047
慕村225694
相关分类