Javascript ohe jquery

Ich will mit Javascript erreichen das nach 5 Sekunden die Maus versteckt wird.

Der hier verwendete Code

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script> <style> body{ height:100vh; width:100vw; font-size:100px; } </style> <body> Inhalt <div id="hint"></div> </body> <script> var sekunden=5; var timer, status=0; var x1=0, x2=0, y1=0, y2=0; bod=document.getElementsByTagName('body')[0]; hinweiss=document.getElementById('hint'); bod.addEventListener('mousemove',function(event){ if(x1==0 && y1==0) { x1=event.screenX; y1=event.screenY; setTimeout('x1=0; y1=0',40); } x2=event.screenX; y2=event.screenY; setTimeout('x2=0; y2=0',40); if(x1 != x2 || y1 != y2) timerStart(); }); function timerCheck() { if(status==1) { timer-=1; if(timer>0) { setTimeout('timerCheck()',1000); bod.style.cursor='default'; hinweiss.innerHTML='Maus verschwindet in '+timer+' Sekunden'; }else{ bod.style.cursor='none'; status=0; hinweiss.innerHTML=''; } } } function timerStart() { timer=sekunden; if(status==0) { status=1; timerCheck(); } } </script>

Add Comment

* Required information
1000
Drag & drop images (max 3)
Powered by Commentics

Comments

No comments yet. Be the first!