gpt4 book ai didi

jquery - 将一个 div 替换为另一个

转载 作者:太空宇宙 更新时间:2023-11-03 22:43:58 25 4
gpt4 key购买 nike

有 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com