Skip to content

Instantly share code, notes, and snippets.

@se77en se77en/index.html
Last active Aug 29, 2015

Embed
What would you like to do?
gbRVbX
<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>
$(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();
})
};
body{
margin:50px;
background-color:#2C3437;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.