JSFiddle - React, Tailwind, and code Playground

by 규연 황

HTML

<form action="">
  <input type="text">
  <input type="text">
  <input type="text">
  <button type="submit">전송</button>
</form>

CSS

form {
  margin: 30px;
}
button,
input {
  display: block;
  height: 30px;
  margin: 10px 0;
}

JavaScript

const form = document.querySelector('form');

form.addEventListener('focusout', event => {
	
  if(form.contains(event.relatedTarget)) {
  	console.log("포커스가 있는 요소간의 이동")
  	return;
  }
  console.log("포커스가 있는 요소에서 포커스 아웃 됐을 경우")
})