我有一些HTML代码看起来像这样:
<tr id="nbContent_GR1">...</tr>
<tr id="nbContent_GR2">...</tr>
<tr id="nbContent_GR3">...</tr>
<tr id="nbContent_GR4">...</tr>
<tr id="nbContent_GR5">...</tr>
<tr id="nbContent_GR6">...</tr>
在其中一行中,我想向上遍历DOM树以查找最接近的具有ID属性以"nbContent_GR"开头的元素。因此,基本上我想能够找到父TR元素而不知道它的确切ID,只需找到以"nbContent_GR"开头的第一个元素。这种情况可能吗?如果可以,我该如何实现?
顺便说一下,我知道closest()和"contains"选择器,只是不确定是否可以在属性值上使用contains。