jQuery根据div id获取指定div中的第一个table
时间: 2024-03-17 21:43:31 浏览: 32
可以使用如下代码:
```javascript
var firstTable = $('#yourDivId').find('table:first');
```
其中,`$('#yourDivId')` 选取指定 `id` 为 `yourDivId` 的 `div` 元素,`.find('table:first')` 查找其中第一个 `table` 元素。最终,`firstTable` 变量就是所需的第一个 `table` 元素。
相关问题
使用jQuery获取div下的第一个table
可以使用如下代码:
```javascript
var firstTable = $('div').find('table:first');
```
其中,`$('div')` 选取所有的 `div` 元素,`.find('table:first')` 查找其中第一个 `table` 元素。最终,`firstTable` 变量就是所需的第一个 `table` 元素。
jquery获取class = 'lbxxdy-table'的div的 子div最后一个
您可以使用 jQuery 的 `:last-child` 选择器来获取 class 为 `'lbxxdy-table'` 的 div 的最后一个子 div。以下是一个示例代码:
```javascript
var lastChildDiv = $('.lbxxdy-table > div:last-child');
```
这将选择 class 为 `'lbxxdy-table'` 的 div 的最后一个子 div 并将其存储在变量 `lastChildDiv` 中。您可以根据需要进一步操作或访问该元素。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)