HeIloWorld
2016-07-18 16:49
采纳率: 50%
浏览 9.6k
已采纳

怎么在<div>里调用js函数

从网上找的正计时代码

`<script type="text/javascript" language="javascript">
function thenceThen(timespan) {
var date1 = new Date(timespan);
var totalSecs = (new Date() - date1) / 1000;
var days = Math.floor(totalSecs / 3600 / 24);
var hours = Math.floor((totalSecs - days * 24 * 3600) / 3600);
var mins = Math.floor((totalSecs - days * 24 * 3600 - hours * 3600) / 60);
var secs = Math.floor((totalSecs - days * 24 * 3600 - hours * 3600 - mins * 60));
document.getElementById("thenceThen").innerText = timespan + "距今:" + days + "天" + hours + "小时" + mins + "分钟" + secs + "秒";
}
var clock;
window.onload = function() {
clock = self.setInterval("thenceThen('2016/06/08')", 500);
}


效果如下
![图片说明](https://img-ask.csdn.net/upload/201607/19/1468860482_813666.png)

我想把以上的天、时、分、秒单独放在下面的几个<div>里,让每个框显示对应的数据


                        <div class="dash days_dash wow zoomIn" data-wow-delay="0.4s">
                            <div class="digit"> </script></div>
                            <span class="dash_title">days</span>
                        </div>
                        <div class="dash hours_dash wow zoomIn" data-wow-delay="0.5s">
                            <div class="digit">hours</div>
                            <span class="dash_title">hours</span>
                        </div>
                        <div class="dash minutes_dash wow zoomIn" data-wow-delay="0.6s">
                            <div class="digit">mins</div>
                            <span class="dash_title">minutes</span>
                        </div>
                        <div class="dash seconds_dash wow zoomIn" data-wow-delay="0.7s">
                            <div class="digit">secs</div>
                            <span class="dash_title">seconds</span>
                        </div>

![图片说明](https://img-ask.csdn.net/upload/201607/19/1468860546_102250.png)

请问代码要如何删改?

3条回答 默认 最新

相关推荐 更多相似问题