标签:http alt bsp code div ready document length bubuko
效果:
<div class="sj"> <span></span>年 <span></span>月 <span></span>日 <span></span>: <span></span>: <span></span> </div>
<script> $(document).ready(function() { function time() { var date = new Date(); var n = date.getFullYear(); var y = date.getMonth()+1; var t = date.getDate(); var h = date.getHours(); var m = date.getMinutes(); var s = date.getSeconds(); $(‘.sj span‘).eq(0).html(n); $(‘.sj span‘).eq(1).html(y); $(‘.sj span‘).eq(2).html(t); $(‘.sj span‘).eq(3).html(h); $(‘.sj span‘).eq(4).html(m); $(‘.sj span‘).eq(5).html(s); for (var i = 0; i < $(‘div‘).length; i++) { if ($(‘div‘).eq(i).text().length == 1) { $(‘div‘).eq(i).html(function(index, html) { return 0 + html; }); } } } time(); setInterval(time, 1000); }); <script>
标签:http alt bsp code div ready document length bubuko
原文地址:https://www.cnblogs.com/BlackFungus/p/9109138.html