Javascript Jquery通过具有多个类的表进行循环

Javascript Jquery通过具有多个类的表进行循环,javascript,jquery,html,ajax,Javascript,Jquery,Html,Ajax,在AJAX调用使用Jquery完成后,我尝试循环遍历该表。但我无法循环通过它。 我的HTML如下所示: <table id="planyourwork" class="data-view plan-internal displayTable"> <thead>All Headers</thead> <tbody> <tr class="odd"> <

在AJAX调用使用Jquery完成后,我尝试循环遍历该表。但我无法循环通过它。 我的HTML如下所示:

    <table id="planyourwork" class="data-view plan-internal displayTable">
     <thead>All Headers</thead>
     <tbody>
          <tr class="odd">
                 <td class="invisible"></td>
                 ....
                 ....
                 <td class="cell-status"></td>
          </tr>
          <tr class="odd">
                 <td class="invisible"></td>
                 ....
                 ....
                 <td class="cell-status"></td>
          </tr>


          <tr class="odd">
                 <td class="invisible"></td>
                 ....
                 ....
                 <td class="cell-status"></td>
          </tr>

     <tbody>
当我调试时,我看到循环没有通过。调试器正在数据视图处停止,但未循环通过

请帮我解决这个问题

下面是整个点击事件

filterBtn.click(function() {
            loadData();
            $('#planyourworktd.cell-status').each(function() {
                var typeCell = $(this);
                var tooltip = typeCell.parent().find('td.fullNotes').html();
                alert("tooltip");
                typeCell.attr('title', tooltip);
                typeCell.tooltip({track: true,show: 100});
            });
            return false;
        });

// Load the request and planner data
        function loadData() {
         $.ajax({
                type: 'post',
                url: url,
                data: data,
                cache: false,
                success: function(html) {
                    initResults();
                         enableButtons();
                },
                error: function(jqXHR, textStatus, errorThrown) {
                    filterBtn.removeClass('invisible');
                },
                async: true
             });
        }
DOM结构非常复杂,当我在小提琴中运行它时,它可以工作,但不能在页面上运行。我不知道为什么?谢谢大家帮助我解决这个问题。
请注意:语法检查可能是打字错误,因为我正在删除生产代码,对此表示抱歉

您的html和javascript中有一些错误,但我不能确定您在这里键入时是否有错误

无论如何

  • “”未关闭,您有另一个“”而不是“”
  • 您的javascript没有正确关闭,下面是它的外观

    $('.data view>tbody>tr>td.cell-status')。每个(函数(){ console.log(this); });

  • 注意额外的“;”最后


    现在,当我进行这些更改时,输出正常。

    我解决了这个问题。这很“可悲”,我错过了几点。我正在使用struts 2和AJAX调用。当AJAX调用完成时,会调用我的事件,但在调用时,数据不会加载。原因是,当进行AJAX调用时,数据被填充为独立运行的“tile”。其余元素被填充,数据被并行加载。更改页面的位置解决了问题。感谢您的帮助。

    分享您的ajax通话。。。我假设你的循环不在成功回调中-它对我有效@Arun你怎么说,当我这么说的时候。“我说调试器也指向这条线。”库马尔。您在JS中的语法不正确。您丢失了
    位于第三行的末尾。另外,如果您的选择器只是
    td.cell status
    ,那就足够了;)@柯特:你说得对!它应该是
    #planyourwork td.cell status
    filterBtn.click(function() {
                loadData();
                $('#planyourworktd.cell-status').each(function() {
                    var typeCell = $(this);
                    var tooltip = typeCell.parent().find('td.fullNotes').html();
                    alert("tooltip");
                    typeCell.attr('title', tooltip);
                    typeCell.tooltip({track: true,show: 100});
                });
                return false;
            });
    
    // Load the request and planner data
            function loadData() {
             $.ajax({
                    type: 'post',
                    url: url,
                    data: data,
                    cache: false,
                    success: function(html) {
                        initResults();
                             enableButtons();
                    },
                    error: function(jqXHR, textStatus, errorThrown) {
                        filterBtn.removeClass('invisible');
                    },
                    async: true
                 });
            }