Return the timeout to a common variable so it can be cleared if the mouse enters the intro-wrapper
element, and reattached if the mouse leaves that element again :
var timer;
$(".btn").on('click', function() {
$(".intro-wrapper").slideDown(300);
timer = setTimeout(function() {
$(".intro-wrapper").slideUp(300);
}, 5000);
});
$( ".intro-wrapper" ).on({
mouseenter: function() {
clearTimeout(timer);
},
mouseleave: function() {
timer = setTimeout(function() {
$(".intro-wrapper").slideUp(300);
}, 5000);
}
});
and note that $('btn')
selects an element looking like <btn></btn>
which is not valid, and you'd normally not use the period when declaring a class
<div class=".intro-wrapper notH
// ^^ woot