WordPress网站。
我想要jquery或php或任何简单的解决方案,它将从div id = content抓取div(如果存在),并将其放在id = iframer div中,而在加载时将其删除到id = content中。
<div id="iframer">
**/ I am waitting to get "<div class="video">All content </div>" inside me. /**
</div>
<div id="content">
<div class="video">
<iframe width="697" height="392" src="https://www.youtube.com/embed/xxxxxxx?feature=oembed" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen=""></iframe>
</div>
</div>
脚本执行后的结果...
<div id="iframer">
<div class="video">
<iframe width="697" height="392" src="https://www.youtube.com/embed/xxxxxxx?feature=oembed" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen=""></iframe>
</div>
</div>
<div id="content">
**/ Iframer stolen my content. /**
</div>
不知道为什么不能直接编辑HTML或生成该HTML的代码,但这是我使用javascript / jQuery的解决方案。
<script>
//A page can't be manipulated safely until the document is "ready."
$( document ).ready(function() {
//Get the html content inside div with id='content'
var myHtml = $( '#content' ).html();
//Copy the HTML in the div with id='iframer'
$( '#iframer' ).html( myHtml );
//Delete the HTML content inside div with id='content'
$( '#content' ).html( '' );
});
</script>
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句