有 2 个 div。
这是代码
<p style="text-align: center;">
<video id="preview" controls style="border: 1px solid rgb(15, 158, 238); height: 280px; width: 300px;" muted="muted" ;></video>
</p>
<input type="button" id="record" class="btn btn-default" style="background: #ffcf00; color: black; height: 40px;text-shadow: none" value="Запись" onclick="doTimer()"/>
<button id="stop" class="btn btn-default" style="background: #ffcf00; color: black; height: 40px;text-shadow: none" disabled>Остановить</button>
<div id="container" style="padding:1em 2em;"></div>
我需要用容器替换预览
这是我写的
$('#preview').replaceWith('#container');
但它只是粘贴word容器而不是div
错在哪里?
最佳答案
您现在附加字符串 #container
您需要使用 html()
方法实际获取该选择器的 html,因此您的代码应该是:
$('#preview').replaceWith($('#container').html());
关于jquery - 将一个 div 替换为另一个,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42899844/