开发者

How to keep td style elements that a function is removing?

开发者 https://www.devze.com 2023-04-12 18:28 出处:网络
This code is part of a fixedtableheader program.However, when you turn on a pager feature (adds some arrows at the bottom of the table so you can advance forward pages at a time), it loses the style i

This code is part of a fixedtableheader program. However, when you turn on a pager feature (adds some arrows at the bottom of the table so you can advance forward pages at a time), it loses the style information that was in my tables' td values. I want to modify this code so that it gets the开发者_如何学Python td elements first from the my tds and add them as well to the td it creates. Can somebody help with this?

Here is the function causing the lose of td elements for the same of adding class="ui-widget-content". By the way, when I do not use the pager option, my style information remains, so I am not even sure 100% this is the cause, but I would like to try adding the elements back here if you can provide input on how to do tihs to see if that works.

    function objectToTable(objectArray,table){
        var body=$('tbody',table);
        body.children().remove();
        for(var i=0;i<objectArray.length;i++){
             tr=$('<tr></tr>');
             for(var j in objectArray[i]){
                  tr.append($('<td class="ui-widget-content"></td>').html(objectArray[i][j]));
             }
             body.append(tr);
        }
    }

Thanks in advance for your help.


Without knowing more about your web page simply adding the class in there with jQuery should do it.

$('td').addClass("ui-widget-content"); 

I suggest you modify the selector though for just the td elements instead of all of them on the page which this will do.

0

精彩评论

暂无评论...
验证码 换一张
取 消