const profile = document.querySelector('#profile');
profile.addEventListener('mouseover', function() { 
   console.log('parent')
   const onHover = document.createElement('div');
   const hoverContent = document.createTextNode('my profile');
   onHover.setAttribute('id', 'miniProfile');
   onHover.append(hoverContent);
   onHover.style.height = '100px';
   onHover.style.width = '100px';
   onHover.style.backgroundColor = 'blue';
   onHover.style.position = 'absolute';
   onHover.style.top = '30px';
   this.append(onHover)
   setTimeout(()=> {
       onHover.style.top = '15px';
       onHover.style.transition = '1s'
       onHover.style.transitionTimingFunction = 'ease'
   }, 10)
    onHover.addEventListener('mouseover', function(e) { 
       // e.stopPropagation()
    })
})
profile.addEventListener('mouseout', function(e) { 
    
    if(e.relatedTarget.id.toLowerCase() !=        this.children[0].id.toLowerCase()) {
        console.log(this.children) 
        if(this.children.length != 0) { 
            for(let i = 0; i < this.children.length; i++) { 
                this.children[i].remove();
            }
        }
    }
})#profile { 
    position: relative;
    display: inline-block;
    margin-left:100px;
    margin-top:50px;
    padding: 10px;
    background-color: red;
}<div id="profile">My Profile</div>When you hover over the red parent box, and then without hovering over the blue child box, you just hover out of the parent blue box, the log shows this:
HTMLCollection [div#miniProfile, miniProfile: div#miniProfile]
but when you open it, the length property shows 0. Here's a snapshot:
Why?
Also, if you hover over the child blue box, you will generate a lot of new child elements, then when you hover out, you get an HTML collection with a lot of elements inside, but the length is almost always close to half the actual elements.
Here's a snapshot:
..again, why?


