我对Jquery不熟悉,但希望我能在一个问题上得到一些帮助。
我创建了这段代码:
if( jQuery.inArray(categoryList, movieArray) == -1 ){
$('<h3 class="category"></h3>').html(categoryList).appendTo('#movieList');
movieArray.push(categoryList);
$("#movieList").append("<thead><tr><th class='long'>" + txtTitle + "</th><th>" + txtLength + "</th><th>" + txtLanguage + "</th></thead>");
}
var rows = "<tr><td>" + title + "</td><td>" + movieTime + "</td><td>" + language + "</td></tr>";
$("#movieList").append(rows);
});
$('#movieList .category').each(function(){
var $set = $(this).nextUntil(".category");
$set.wrapAll('<div class="movieTable"><table class="table dataTable"></table></div>');
});
基本上,我希望能够包装在标签内生成的TR标签组。原因是我想使用表格分类器插件,但除非表格区分THEAD和TBODY
,否则它不起作用答案 0 :(得分:0)
为什么不只是追加表格,然后将行追加到正确的类别?我不知道这个函数是如何运行的,但我认为这可能有用:
if( jQuery.inArray(categoryList, movieArray) == -1 ){
$('<h3 class="category"></h3>').html(categoryList).appendTo('#movieList');
movieArray.push(categoryList);
$("#movieList").append("<div class='movieTable'><table class='table dataTable " + categoryList + "'><thead><tr><th class='long'>" + txtTitle + "</th><th>" + txtLength + "</th><th>" + txtLanguage + "</th></thead><tbody></tbody></table></div>");
}
$('table.' + categoryList).find('tbody').append("<tr><td>" + title + "</td><td>" + movieTime + "</td><td>" + language + "</td></tr>");
如果这不起作用,那么如果您提供基本演示会有所帮助。