如何使用 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
如何在最近的標簽中找到類?
躍然一笑
2023-05-25 16:51:00