JSFiddle - React, Tailwind, and code Playground
HTML
<script src="//fast.wistia.com/assets/external/E-v1.js"></script>
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<div class="wrap">
<div class="wistia_embed wistia_async_29b0fbf547" style="width:340px;height:240px;"> </div>
</div>
<button id="remove">
remove
</button>
JavaScript
var wrap = $('.wrap'),
player;
window._wq = window._wq || [];
_wq.push({
id: "29b0fbf547",
onReady: function(video) {
player = video;
console.log('onReady')
}
});
$('#remove').on('click', function() {
if (player) {
player.remove();
player = null;
}
wrap.empty();
setTimeout(function() {
console.log(1)
$('<div class="wistia_embed wistia_async_29b0fbf547" style="width:340px;height:240px;"></div>').appendTo(wrap);
_wq.push({
id: "29b0fbf547",
onReady: function(video) {
player = video;
console.log('onReady')
}
});
}, 500)
})