我正在尝试选择类this
,然后在that
不先遍历父tr
元素的情况下获取。
这是我的 HTML:
<tr>
<td>
<div>some content</div>
<select class="this">
<option>1</option>
<option>2</option>
</select>
</td>
</tr>
<tr>
<td>
<div>some content</div>
<select class="that">
<option>1</option>
<option>2</option>
</select>
</td>
</tr>
这是我的 jQuery:
$('.this').each(function () {
var thisSelect = $(this),
thatSelect = $(thisSelect).next('.that');
console.log(thatSelect); // doesn't work
});
我尝试使用上面的代码,但没有成功。我正在使用each
函数,因为页面上有不止一组这些选择元素。