2014-12-03 18 views
-1

下面的代碼工作只是偉大的TRS也有在HTML爲什麼我沒有得到動態創建的TR的結果?

JS小提琴:enter link description here

  var data = []; 
      table.find('tr.trMyRow').each(function (rowIndex, r) { 
       var cols = []; 
       $(this).find('th,td').each(function (colIndex, c) { 

        $(this).find("input.classKey").each(function (inputIndex, j){ 
         console.log(j); 
        }); 

        $(this).find("input.classValue").each(function (input2Index, g){ 
         console.log(g); 
        }); 

        cols.push(c.textContent); 
       }); 
       data.push(cols); 
      }); 

但當TRS被動態地從.append("<tr class='trMyRow'>etc...")創建者它不被選擇取回,任何想法?

+0

你在哪裏在你的應用程序中運行這段代碼?它是更大功能的一部分嗎?它只在頁面加載後才運行?在錶行被動態創建後它再次運行嗎? – Larz 2014-12-03 21:42:36

+0

jquery代碼位於我的頁面主體,是的它運行在動態創建的行之後 – RollRoll 2014-12-03 21:52:03

+0

你真的用這個確切的代碼追加你的表嗎? '.append(「 etc ...」)'或者你確定要添加這樣的類名? '.append(「 etc ...」)?' – Larz 2014-12-03 21:58:45

回答

0

您應該將tbMyTable類添加到附加的tr .append("<tr class='tbMyTable'>etc...")

相關問題