Skip to content

Instantly share code, notes, and snippets.

@se77en
Last active August 29, 2015 14:14
Show Gist options
  • Save se77en/1be6780c3c1206c11bf0 to your computer and use it in GitHub Desktop.
Save se77en/1be6780c3c1206c11bf0 to your computer and use it in GitHub Desktop.
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