在我下面的第二个表的代码中,它没有保留相同的代码,它似乎被第一个表中的代码覆盖。
有没有办法让我可以保留代码但仍将我的表替换为 div 和 span?
<script>
$(document).ready(function() {
$('table').replaceWith( $('table').html()
.replace(/<tbody/gi, "<div class='table'")
.replace(/<tr/gi, "<div class='ccbnOutline'")
.replace(/<\/tr>/gi, "</div>")
.replace(/<td/gi, "<span")
.replace(/<\/td>/gi, "</span>")
.replace(/<\/tbody/gi, "<\/div")
);
});
</script>
</head>
<body>
<!-- This will be changed into div's and span's -->
<table width="100%" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td>one</td>
<td>two</td>
<td>three</td>
</tr>
</tbody>
</table>
<!-- End of Example Table -->
<!-- This will be changed into div's and span's -->
<table width="100%" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td>one123</td>
<td>two123</td>
<td>three123</td>
</tr>
</tbody>
</table>
<!-- End of Example Table -->