A Pen by Damon Zhao on CodePen.
Last active
August 29, 2015 14:14
-
-
Save se77en/1be6780c3c1206c11bf0 to your computer and use it in GitHub Desktop.
gbRVbX
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html xmlns="http://www.w3.org/1999/xhtml"> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> | |
<script class="jquery library" src="/js/sandbox/jquery/jquery-1.8.2.min.js" type="text/javascript"></script> | |
<title>RunJS 演示代码</title> | |
</head> | |
<body> | |
<div id="con"> | |
abcdefghijklmn | |
</div> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function(){ | |
createTimer(); | |
}); | |
function Notice(time) { | |
var speed = time || 3000, | |
count = 5; | |
Notice.prototype.play = function() { | |
t = setInterval(function() { | |
if (count > 0) { | |
alert(count); | |
count--; | |
} else { | |
clearInterval(t); | |
t = 0; | |
} | |
}, speed); | |
}; | |
Notice.prototype.pause = function() { | |
clearInterval(t); | |
}; | |
} | |
var createTimer = function() { | |
var ntc = new Notice(); | |
ntc.play(10000); | |
var el = $('#con'); | |
el.on('mouseover', function(e) { | |
ntc.pause(); | |
}).on('mouseleave', function(e) { | |
ntc.play(); | |
}) | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
body{ | |
margin:50px; | |
background-color:#2C3437; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment