Advertisement
Maxim_01

Untitled

Mar 16th, 2023
457
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function focused() {
  2.    
  3.     let inputArray = Array.from(document.querySelectorAll("input"))
  4.  
  5.     for (const input of inputArray) {
  6.  
  7.         input.addEventListener("click", clickHandler)
  8.         input.addEventListener("blur", blurHandler)
  9.  
  10.     }
  11.  
  12.     function clickHandler(e){
  13.  
  14.         let input = e.currentTarget
  15.         let divParent = input.parentElement
  16.         divParent.className = "focused"
  17.  
  18.     }
  19.  
  20.     function blurHandler(e){
  21.         let input = e.currentTarget
  22.         let divParent = input.parentElement
  23.         divParent.className = ""
  24.  
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement