JSFiddle - React, Tailwind, and code Playground

by 규연 황

HTML

<div>
    <button type="button" id="capture">카메라 전면/후면</button>

  </div>
  <input type="file" name="" id="camera" accept="video/*" capture="user">
  <!-- <input type="file" name="" id="" accept="video/*" capture="environment"> -->


  <script>
const capture = document.getElementById('capture')
const camera = document.getElementById('camera')

console.log(camera.getAttribute('capture'))
capture.addEventListener('click', function(e) {
  const cap = camera.getAttribute('capture')
  if(cap == 'user') {
    camera.setAttribute('capture', 'environment')
  } else {
    camera.setAttribute('capture', 'user')
  }
  console.log(cap)
  
})
  </script>