Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/400.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript html表格中的条件格式_Javascript_Jquery_Html - Fatal编程技术网

Javascript html表格中的条件格式

Javascript html表格中的条件格式,javascript,jquery,html,Javascript,Jquery,Html,我已经在HTML表中使用jquery完成了条件格式设置。在datatable的第1页,它工作正常,但从第2页开始,它就不工作了。我正在使用以下代码: $("table.dataTable td:nth-child(6)").each(function () { if (parseInt($(this).text(), 10) > 0) { $(this).parent("tr").css("backgroun

我已经在HTML表中使用jquery完成了条件格式设置。在datatable的第1页,它工作正常,但从第2页开始,它就不工作了。我正在使用以下代码:

   $("table.dataTable td:nth-child(6)").each(function () {

                if (parseInt($(this).text(), 10) > 0) {

                    $(this).parent("tr").css("background-color", "#baf2ef");
                    $('tr').each(function () {
                        var tds = $(this).find('td');
                        var len = tds.length;

                        for (var i = 0; i < len; i++) {
                            $(tds[i]).css('text-align', 'center');
                            // $(tds[i]).css('white-space', 'nowrap');
                        }
                    });
                }

                else {

                    $('tr').each(function () {
                        var tds = $(this).find('td');
                        var len = tds.length;
                        for (var i = 0; i < len; i++) {
                            $(tds[i]).css('text-align', 'center');
                            // $(tds[i]).css('white-space', 'nowrap');
                        }
                    });
                }
            });
$(“table.dataTable td:nth child(6)”)。每个(函数(){
if(parseInt($(this).text(),10)>0){
$(this.parent(“tr”).css(“背景色”,“#baf2ef”);
$('tr')。每个(函数(){
var tds=$(this.find('td');
var len=tds.长度;
对于(变量i=0;i

请提供帮助。

您必须在datatable的页面事件上执行js功能

$('table.dataTable').on('page.dt', function () {
    //your code here
});
这还没有经过测试,您可能需要处理一个问题:代码可能在寻呼机加载内容之前执行


让我知道,

行背景颜色有问题吗?我想每次页面更改时都必须调用代码。@HamzaAbdaoui是。@ADreNaLiNe DJ怎么能调用它?我使用具有分页功能的引导数据表property@All我需要…请帮忙!!