jQuery循环从html表中提取一行数据 [英] jquery loop to extract a row of data from html table

查看:83
本文介绍了jQuery循环从html表中提取一行数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我是jquery的新手,它是我使用的第一个JavaScript,一直在网上和其他地方使用,但希望对此有所帮助.

我有一个包含17列的html表,第一个包含说明,然后其他16个包含过去16周的数据.

因此,说第一行是出勤率,过去16周的出勤率,然后是第二行缺勤,其次是同期的统计信息.

因此,从我可以看到的角度来看,我必须从与我发现的类似的东西开始...

Hi there,

I''m new at jquery and it''s the first javascript I''ve used, been looking on the net and elsewhere but was hoping to get some help on this.

I have an html table with 17 columns, the first contains descriptions then the other 16 have data for the past 16 weeks.

So say the first row is attendance which will have it for the past 16 weeks, then row 2 absence followed by the stats for the same period.

So from what I can see I would have to start with something similar to this I found...

var myTr = [];
           $('.GridView tr').each(function () {
               $(this).find('td').each(function () {
                   myTr.push($(this).text());
               });
               alert(myTr);
           });
       });




这给了我所有的列标题,实际的目的是将两个[header,value]都提取成对,我可以在jqplot之类的东西中使用它们.因此,当用户单击出勤等时,他们可以查看16周的图表.尽管我看不到如何指示单击表中的哪个单元格,但更不用说获取那一行数据了?

如前所述,我是jquery/javascript的完全新手,因此,如果您知道任何真正有见地的教程,我将不胜感激.
问候!

Lifesigns




This gives me all the column headers, the actual aim is to extract both [header, value] into pairs which I could use in something like jqplot. So when the user clicks on attendance etc they can view a chart for the 16 weeks. Though I don''t see how to indicate which cell in the table was clicked on, let alone get that row of data?

As mentioned I am a COMPLETE newbie to jquery/javascript so if you know of any real insightful tutorials I''d appreciate the input.

Regards!

Lifesigns

推荐答案

(' .GridView tr').each(function(){
('.GridView tr').each(function () {


( this ).find(' td').each(function(){ myTr.push(
(this).find('td').each(function () { myTr.push(


( this ).text()); }); alert(myTr); }); });
(this).text()); }); alert(myTr); }); });




这给了我所有的列标题,实际的目的是将两个[header,value]都提取成对,我可以在jqplot之类的东西中使用.因此,当用户单击出勤等时,他们可以查看16周的图表.尽管我看不到如何指示单击表中的哪个单元格,但更不用说获取该行的数据了?

如前所述,我是jquery/javascript的完全新手,因此,如果您知道任何真正有见地的教程,我将不胜感激.
问候!

生命迹象




This gives me all the column headers, the actual aim is to extract both [header, value] into pairs which I could use in something like jqplot. So when the user clicks on attendance etc they can view a chart for the 16 weeks. Though I don''t see how to indicate which cell in the table was clicked on, let alone get that row of data?

As mentioned I am a COMPLETE newbie to jquery/javascript so if you know of any real insightful tutorials I''d appreciate the input.

Regards!

Lifesigns


这篇关于jQuery循环从html表中提取一行数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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