I am trying to better understand scope and chaining in javascript. I have the following which works just fine
$("div.sked, div.report, div.database").hover (function (){
let $this = $(this);
let $pos = $this.position();
$submenu = $this.find (":first-child");
$submenu.css ('left', $pos.left + 30);
$submenu.css ('top', $top);
$submenu.show();
})
.mouseleave (function (){
$submenu.hide();
});
But when I add a let before $submenu = $this.find (":first-child");
Then $submenu goes out of scope and submenus are not hidden.
I would like top understand the proper way to code this.
Thank you...