我有一个包含计数器的网站,并且<h3 id="counter">0</h3>
。如何更改计数器编号?我在哪里可以找到它改变?
这是代码:
<div class="container">
<div class="row">
<div class="col-md-4 project">
<h3 id="counter">0</h3>
<h4>Awesome Projects</h4>
<p>Dolor sit amet, consectetur adipiscing elit quisque tempus eget diam et lorem a laoreet phasellus ut nisi id leo molestie. </p>
</div>
<div class="col-md-4 project">
<h3 id="counter1">0</h3>
<h4>Happy Customers</h4>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit quisque tempus eget diam et. laoreet phasellus ut nisi id leo. </p>
</div>
<div class="col-md-4 project">
<h3 id="counter2" style="margin-left: 20px;">0</h3>
<h4 style="margin-left: 20px;">Professional Awards</h4>
<p>Consectetur adipiscing elit quisque tempus eget diam et laoreet phasellus ut nisi id leo molestie adipiscing vitae a vel. </p>
</div>
</div>
</div>
答案 0 :(得分:1)
将以下内容添加到HTML中:
<script type="text/javascript">
var count = 0;
// adds 1 to count every 1000 milliseconds and updates it for the user
window.setInterval(function()
{
count++;
document.getElementById("counter").innerHTML = count;
}, 1000);
</script>