每天CookBook之JavaScript-014

  • setTimeout的使用
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>014</title>
</head>
<body>
    
</body>
<script type="text/javascript">
var firstDate = new Date();
setTimeout(function() {
    var secondDate = new Date();
    var diff = secondDate - firstDate;
    console.log(diff);
}, 2000);
</script>
</html>
posted @ 2016-07-09 11:09  4Thing  阅读(98)  评论(0编辑  收藏  举报