jquery - 使用 tablesorter jquery 在表中添加一行

标签 jquery css row tablesorter

我有一个用 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/

相关文章:

html - CSS 相对位置与绝对位置

wpf - 从 X 和 Y 位置获取网格行和列

mysql - 修改查询以使其执行速度更快,但仍然得到相同的结果

jQuery 函数 .split() 不起作用,AJAX 数据未提交

javascript - 通过 id js 定位?

javascript - jQuery 每个函数不使用数组的顺序

r - 选择变量值等于某个向量的行

jquery - 删除加载的 jQuery AJAX 元素

javascript - 为 Shiny 应用程序添加 'Calculation In Process' 指示器

html - 如何水平居中固定定位的元素