Advertisement
kstoyanov

06. Highlight Active

Oct 1st, 2020
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function focus() {
  2.     const inputs = document.querySelectorAll('input[type=text]');
  3.     Array.from(inputs).forEach(i => i.addEventListener('focus', focusIn));
  4.     Array.from(inputs).forEach(i => i.addEventListener('blur', focusOut));
  5.  
  6.     function focusIn(e) {
  7.         e.target.parentElement.classList.add('focused');
  8.     }
  9.  
  10.     function focusOut(e) {
  11.         e.target.parentElement.classList.remove('focused');
  12.     }
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement