将表数据存储到jquery变量 [英] Store table data to a jquery variable
本文介绍了将表数据存储到jquery变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想将表中的数据存储到jquery变量中,使用的代码如下所示,但是这段代码将所有表标签(如tr,td和all)存储到变量中,其中我只需要存储td标签中的数据以文本格式发送到jquery变量..有人可以帮忙吗?
I want to store data in a table to a jquery variable, the code im using is as below, but this code is storing all table tags like tr, td and everything to the variable, where as i just need to store the data in td tag in text format to a jquery variable..can anyone help?
var table = $("#mytable").html();
推荐答案
您可以像这样收集单元格值:
You can collect the cell values like this:
arr = new Array();
$("td").each(function () {
t = $(this).text();
arr.push(t);
});
console.log(arr);
这篇关于将表数据存储到jquery变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文