我有一个用 jquery 库“Tablesorter”构建的表,当我点击一个按钮时我想在这个表中添加一行但是当我添加行时,这不需要 tablesorter 的 css ..所以我不能选择他,或者 css“奇数”“偶数”不起作用..
$("#ajouterCodePiece").click(function(){
$('#tablesorter-demo-gauche tr:last').after('<tr'><td>'+$('#codepiece option:selected').text()+'</td><td>'+$('#mode option:selected').text()+'</td></tr>');
});
我该怎么做才能在我的新行中添加 tablesorter 的 css 和 jquery .. 谢谢
最佳答案
Tablesorter 将所有表格内容存储在缓存中,因此为了告诉 tablesorter 某些内容已更改,您需要触发更新:
$('table').trigger('update');
这这这updated demo
$("#ajouterCodePiece").click(function () {
$('#tablesorter-demo-gauche tr:last').after('<tr><td>' + $('#codepiece option:selected').text() + '</td><td>' + $('#mode option:selected').text() + '</td></tr>');
$('#tablesorter-demo-gauche').trigger('update');
});
关于jquery - 使用 tablesorter jquery 在表中添加一行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21910794/