jQuery/javascript replace tag type

后端 未结 8 1552
抹茶落季
抹茶落季 2020-12-02 23:42

Is there an easy way to loop through all td tags and change them to th? (etc).

My current approach would be to wrap them with the th and then remove the td, but then

8条回答
  •  时光说笑
    2020-12-03 00:20

    This might work, but I haven't tested it extensively:

    var tds = document.getElementsByTagName("td");
    while(tds[0]){
        var t = document.createElement("th");
        var a = tds[0].attributes;
        for(var i=0;i

    I hope it helps in some way.

提交回复
热议问题