JSFiddle - React, Tailwind, and code Playground

by lchau

HTML

<script src="https://testplayer.twitch.tv/prototype_imdb_fix/js/embed/v1.js"></script>
<div id='player1'></div>
<button id='button'>
  click
</button>
<div id='player2'></div>

JavaScript

const player1 = document.getElementById('player1');
const player = new Twitch.Player(player1, { video: 'v123802735' });
document.getElementById('button').addEventListener('click', event => {
  const a = document.getElementById('player1');
  const a_player = a.querySelector('iframe');
  const b = document.getElementById('player2');

  if (a_player) {
    b.appendChild(a_player);
  } else {
    const b_player = b.querySelector('iframe');
    a.appendChild(b_player);
  }
});