Advertisement
pacho_the_python

Untitled

Dec 2nd, 2023
598
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function clickMe() {
  2.     let btnElement = document.getElementById('click')
  3.     let sectionElement = document.getElementById('section')
  4.    
  5.     btnElement.addEventListener('mouseenter', deleteElement)
  6.  
  7.     function deleteElement() {
  8.         sectionElement.removeChild(btnElement)
  9.  
  10.         let newBtn = document.createElement('button')
  11.         newBtn.textContent = 'Ice Cream'
  12.         newBtn.id = 'left-btn'
  13.         newBtn.addEventListener('mouseenter', rightFunction)
  14.         sectionElement.appendChild(newBtn)
  15.     }
  16.  
  17.     function rightFunction() {
  18.         elelentToRemove = document.getElementById('left-btn')
  19.         sectionElement.removeChild(elelentToRemove)
  20.  
  21.         let rightBtn = document.createElement('button')
  22.         rightBtn.textContent = 'Ice Cream'
  23.         rightBtn.id = 'right-btn'
  24.         rightBtn.addEventListener('mouseenter', downFunction)
  25.         sectionElement.appendChild(rightBtn)
  26.     }
  27.  
  28.     function downFunction() {
  29.         elelentToRemove = document.getElementById('right-btn')
  30.         sectionElement.removeChild(elelentToRemove)
  31.  
  32.         let downBtnBtn = document.createElement('button')
  33.         downBtnBtn.textContent = 'Ice Cream'
  34.         downBtnBtn.id = 'down-btn'
  35.         downBtnBtn.addEventListener('mouseenter', downLeftFunction)
  36.         sectionElement.appendChild(downBtnBtn)
  37.     }
  38.  
  39.     function downLeftFunction() {
  40.         elelentToRemove = document.getElementById('down-btn')
  41.         sectionElement.removeChild(elelentToRemove)
  42.  
  43.         let downLeftBtn = document.createElement('button')
  44.         downLeftBtn.textContent = 'Ice Cream'
  45.         downLeftBtn.id = 'down-left-btn'
  46.         downLeftBtn.addEventListener('mouseenter', downRightFunction)
  47.         sectionElement.appendChild(downLeftBtn)
  48.     }
  49.  
  50.  
  51.     function downRightFunction() {
  52.         elelentToRemove = document.getElementById('down-left-btn')
  53.         sectionElement.removeChild(elelentToRemove)
  54.  
  55.         let downLeftBtn = document.createElement('button')
  56.         downLeftBtn.textContent = 'Ice Cream'
  57.         downLeftBtn.id = 'down-right-btn'
  58.         downLeftBtn.addEventListener('mouseenter', upperFunction)
  59.         sectionElement.appendChild(downLeftBtn)
  60.     }
  61.  
  62.  
  63.     function upperFunction() {
  64.         elelentToRemove = document.getElementById('down-right-btn')
  65.         sectionElement.removeChild(elelentToRemove)
  66.         sectionElement.appendChild(btnElement)
  67.     }
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement