Jquery 数一数页面上的所有表格,获取它们的id';s和run-through数组

Jquery 数一数页面上的所有表格,获取它们的id';s和run-through数组,jquery,arrays,count,Jquery,Arrays,Count,我有一个页面,上面有许多由php、mysql生成的表。我想在每个表上运行一些jquery 我认为最好的方法是创建一个表ID数组并在foreach中运行jquery 问题是我不知道怎么做,所以如果有人知道怎么做,我将不胜感激 EDIT///这是我希望在每个表上运行的代码 $("#frontshade:radio").click(function() { $(this).parent().children(":checkbox").attr('checked', false); $(

我有一个页面,上面有许多由php、mysql生成的表。我想在每个表上运行一些jquery

我认为最好的方法是创建一个表ID数组并在foreach中运行jquery

问题是我不知道怎么做,所以如果有人知道怎么做,我将不胜感激

EDIT///这是我希望在每个表上运行的代码

    $("#frontshade:radio").click(function() {
  $(this).parent().children(":checkbox").attr('checked', false);
  $(this)
   .closest('table') // find the parent row
       .find(":input[type='text']") // find text elements in that row
           .attr('disabled','disabled') // disable them
           .removeClass('disabled'); //Toggle class
    $("#frontshade :checkbox").hide();
    $("#frontshade .cbox").hide();

    $(this).parent().children(":checkbox").show();
    $(this).parent().children(".cbox").show();
    });
    $("#frontshade :checkbox").click(function(){
    $(this)
   .closest('tr') // find the parent row
     .find(":input[type='text']") // find text elements in that row
       .toggleDisabled()
       .toggleClass('disabled','slow') // enable them
   .end() // go back to the row
   .siblings() // get its siblings
       .find(":input[type='text']") // find text elements in those rows
           .attr('disabled','disabled')
           .removeClass('disabled'); // disable them
});
还是说MySQL表


还是说MySQL表?

要遍历表并获取它们的ID,以及执行您想要的任何其他操作,请执行以下操作:

var table_ids = new Array();
$('table')
    .each(function(e){
        table_ids[] = $(this).attr('id');
        //do other stuff with each table
    });

要遍历表并获取它们的ID,以及执行您想要的任何其他操作,请执行以下操作:

var table_ids = new Array();
$('table')
    .each(function(e){
        table_ids[] = $(this).attr('id');
        //do other stuff with each table
    });

像这样的事情应该让你开始

$('table').each(function(index, table){
    table.find('td').each(function(index, el){
        el.doSomething();
    });
})

像这样的事情应该让你开始

$('table').each(function(index, table){
    table.find('td').each(function(index, el){
        el.doSomething();
    });
})

您知道,以下代码将实现相同的功能:

jQuery('table').each(function() {
    // your code here
});

更多详细信息请参见

您知道,以下代码将实现相同的功能:

jQuery('table').each(function() {
    // your code here
});

更多详细信息,请参见

如果希望表具有相同的脚本,还可以向表中添加一个类,并说:

$('table.doIt').each(function ()
{
    // your code here
}

我认为获取所有ID有点尴尬,因为只需向要在其上运行jQuery的表添加一个类似乎更容易一些。在JS中花费更少的精力,在PHP中只需添加一个额外的类。

如果希望表具有相同的脚本,还可以向表中添加一个类,并说:

$('table.doIt').each(function ()
{
    // your code here
}

我认为获取所有ID有点尴尬,因为只需向要在其上运行jQuery的表添加一个类似乎更容易一些。在JS中花费更少的精力,在PHP中只需额外添加一个类。

谢谢,我如何在每个表上运行此功能我以为我能找到它,但我正在努力查看EditThank,我如何在每个表上运行此功能我以为我能找到它,但我正在努力查看EditThank,我仍在努力实现它,我已经在原始帖子中包含了我想执行的代码。你能添加你的代码吗。包括您的HTML代码。@。告诉我你到底想做什么。我会帮你修好的!我只需要知道如何用循环$(“#frontshade:radio”)中当前表的唯一id替换“#frontshade”。单击(function(){};$(“#frontshade:checkbox”).hide();$(“#frontshade.cbox”).hide();简化的问题和代码谢谢,我仍在努力实现它。我已经在原始帖子中包含了我想要执行的代码。你能添加你的代码吗。包括你的HTML代码。@。并告诉我你到底想做什么。我会帮你解决的!我只需要知道如何用t的唯一id替换“#frontshade”循环中的当前表$(“#frontshade:radio”)。单击(函数(){};$(“#frontshade:checkbox”)。隐藏();$(“#frontshade.cbox”)。隐藏();简化的问题和代码谢谢,我还在努力实现它。我已经在原始帖子中包含了我想要执行的代码。谢谢,我还在努力实现它。我已经在原始帖子中包含了我想要执行的代码。