解决方法
完全未经测试,但给予这个旋转:
$("td").each(function(index) { var thisTD = this; var newElement = $("<th></th>"); $.each(this.attributes,function(index) { $(newElement).attr(thisTD.attributes[index].name,thisTD.attributes[index].value); }); $(this).after(newElement).remove(); });@H_301_2@我正在寻找并看着它,我不能想到为什么它不工作的原因! @H_301_2@1)循环遍历每个td元素 @H_301_2@2)创建一个新的元素 @H_301_2@3)对于每个td,循环其每个属性 @H_301_2@4)将该属性和值添加到新的第th个元素 @H_301_2@5)一旦所有属性都到位,在td之后将元素添加到DOM,并删除td @H_301_2@编辑:工作正常:http://jsbin.com/uqofu3/edit