我在輸入3 divs
,td
和tr
。沒有可用的唯一屬性進行搜索(id和行頻繁更改)。我試圖穿越通過在div
一個label
在相鄰td
開始DOM,轉到next td
,然後通過div
一個div
另一div
下來再進input
。jQuery最接近沒有遍歷父項
我開始與$('[title*="P2P"]').closest('td').next('.control-cell').find('input');
它不選擇輸入我,所以我就開始通過打印的類別在時間選擇的元素1步倒退工作,但一旦突破爲使用closest
到經過第一個div
。
我的jsfiddle:https://jsfiddle.net/28kacj28/
而我的HTML:
<tr class="control">
<td class="label-cell left-label">
<div class="workitemlabel">
<label class="workitemcontrol-label" for="witc_135_txt" title="[Field Name: Process Start Date]">Start Date:</label>
</div>
</td>
<td class="control-cell">
<div class="workitemcontrol">
<div id="witc_135" class="combo input-text-box date-time drop">
<div class="wrap">
<input type="text" id="witc_135_txt" autocomplete="off" maxlength="255" title="7/7/2016 12:00:00 AM" aria-invalid="false">
</div>
<div class="drop bowtie-calendar bowtie-icon"></div>
</div>
</div>
</td>
</tr>
<tr class="control">
<td class="label-cell left-label">
<div class="workitemlabel">
<label class="workitemcontrol-label" for="witc_136_txt" title="[Field Name: P2P]">P2P:</label>
</div>
</td>
<td class="control-cell">
<div class="workitemcontrol">
<div id="witc_136" class="combo input-text-box date-time drop">
<div class="wrap">
<input type="text" id="witc_136_txt" autocomplete="off" maxlength="255" title="7/29/2016 12:00:00 AM" aria-invalid="false">
</div>
<div class="drop bowtie-calendar bowtie-icon"></div>
</div>
</div>
</td>
</tr>
<span></span>
['最接近()'](https://api.jquery.com/closest/)不會做你認爲它。它將遍歷樹的祖先,如「父母()」。 –
testShit未在控制檯中定義 – guradio