写一个函数,html页面上有一个表格,第6列的值是user_id,第7列的值是count,有一个对象user_count,存储的是user_id:count键值对,要实现的功能是:用jquery操作表格,根据第6列的user_id值,设置第7列的值。
时间: 2024-05-25 10:19:07 浏览: 13
function setUserCount(user_count) {
$('table tr').each(function() { //遍历表格每一行
var user_id = $(this).find('td:eq(5)').text(); //获取第6列的user_id值
if (user_count[user_id]) { //如果user_count中存在该user_id
$(this).find('td:eq(6)').text(user_count[user_id]); //设置第7列的值为user_count中对应的count值
}
});
}
相关推荐
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![txt](https://img-home.csdnimg.cn/images/20210720083642.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![doc](https://img-home.csdnimg.cn/images/20210720083327.png)
![pptx](https://img-home.csdnimg.cn/images/20210720083543.png)
![pptx](https://img-home.csdnimg.cn/images/20210720083543.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![doc](https://img-home.csdnimg.cn/images/20210720083327.png)