如何选择div下的第二个表结构? [英] How to select second table structure under a div?

查看:90
本文介绍了如何选择div下的第二个表结构?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图选择 div 下的每一个



所以我的html就像

 < div class ='tableDiv'> 
< table class ='table'>
....
< / table>

< table class ='table'>
....
< / table>

< / div>

...其他东西...

< div class ='tableDiv'>
< table class ='table'>
....
< / table>

< table class ='table'>
....
< / table>
< / div>

其他东西

< div class ='anotherTableDiv'>
< table class ='table'>
....
< / table>

< table class ='table'>
....
< / table>
< / div>

我试图选择' tableDiv

$ b

我试过了。

  $( '.tableDiv表:第n个孩子(偶数)); 

但它不起作用。我无法真正改变课程名称或添加ID,所以它有点困难。任何人都可以给我一个提示吗?非常感谢!

解决方案

使用jQuery的:even p>

  $('。tableDiv table:even')


I am trying to select every second table under a div.

so my html is like

<div class ='tableDiv'>
  <table class='table'>
    ....
  </table>

  <table class='table'>
    ....
  </table>

</div>

...other stuff...

<div class ='tableDiv'>
  <table class='table'>
    ....
  </table>

  <table class='table'>
    ....
  </table>
</div>

other stuff

<div class ='anotherTableDiv'>
  <table class='table'>
    ....
  </table>

  <table class='table'>
    ....
  </table>
</div>

I am trying to select every second table under 'tableDiv' div.

I tried.

$('.tableDiv table:nth-child(even));

but it doesn't work. I can't really change class name or add an ID so it's a bit difficult. Can anyone gives me a hint for it? Thanks a lot!

解决方案

Use jQuery's :even selector.

$('.tableDiv table:even')

这篇关于如何选择div下的第二个表结构?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆