我想在<div class="">
之前添加<table>
,在</div>
之后使用javascript动态添加</table>
。我怎么做。
答案 0 :(得分:1)
答案 1 :(得分:0)
您正在寻找:
$(document).ready(function(){
//before added
console.log($('.main-content').html());
$("button").click(function(){
$("table").wrap("<div class='AddedTag'></div>");
//after added
console.log($('.main-content').html());
});
});
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="main-content">
<table>
<tr>
<th>Test table col</th>
</tr>
</table>
</div>
<button>Click to add</button>
&#13;