扫码关注官方订阅号
amaze amaze amaze amaze
amaze
业精于勤,荒于嬉;行成于思,毁于随。
这应该是你想要的答案,重新优化了一下。
var timeoutObj = null; $("#append").on("mouseenter mouseleave","p",function(e){ if(e.type == "mouseenter"){ //鼠标进入 (function(me){ timeoutObj = setTimeout(function(){ $(me).text("wow"); },3000); }(this)); }else if(e.type == "mouseleave"){ //鼠标离开 $(this).text("amaze"); if(timeoutObj != null){ clearTimeout(timeoutObj); } } });
settimeout(functoin(){},3000)
<script type="text/javascript"> $("#append").on("mouseenter mouseleave","p",function(e){ if(e.type == "mouseenter"){ //鼠标进入 $(this).text("wow"); setTimeout("Onlive()",3000); }else if(e.type == "mouseleave"){ //鼠标离开 $(this).text("amaze"); } }); function Onlive(){ alert("3秒弹出"); } </script>
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
这应该是你想要的答案,重新优化了一下。
settimeout(functoin(){},3000)