It is necessary that the elements disappear when the user does not move the mouse for 5 seconds and that they are shown back as soon as the mouse moves (and so on in a circle).

Maybe there are ready-made plugins or solutions for this problem?

    2 answers 2

    You can add the autohide class to all the elements you need to hide and add this code to the page:

     var timeout = null; $(document).on('mousemove', function() { if (timeout !== null) { $(".autohide").show(); clearTimeout(timeout); } timeout = setTimeout(function() { $('.autohide').hide(); timeout = null; }, 5000); }); 
    • one
      those. each time the mouse pointer moves, is a timer checked? Is it too resource-intensive? - Matvey Safronov
    • tried, does not work - Sdafs Fasafs
    • @SdafsFasafs Very strange. Here is a working example of jsfiddle.net/xue0mg6m - Pyramidhead
    • @ Sebastian Pereiro , it’s really strange that something is not working on my site ( - Sdafs Fasafs
    • @SdafsFasafs, check the console. If this code does not work, then there should be any errors in the console. - Pyramidhead

    I don't know the finished plug-ins, but you should probably start from this and from setTimeout

    • I was ahead with the answer, - Sebastian Pereiro sent you a small piece - Mr. Brightside