我有了类似于下面一节的表:的jQuery:儿童()与孩子选择“>”
<tr>
<td> <span class="myclass"></span>
</td>
<tr>
我的$(本)被设置为TR元素,我想访问具有“myclass”类集的Span元素。 以下似乎工作:
if ($(this).children('td').children('span').is('.myclass')){
alert('in here');
}
而是试图用这个当:
if ($(this).children("td > span").is('.myclass')){
或本:
if ($(this).children("td span").is('.myclass')){
事实并非如此。我认为以上两种中的任何一种都会得出类似的结果(虽然通过不同的方法),但显然不是。
我在这里错过了什么?
谢谢!