简体   繁体   中英

How do I change a counter of the form <h3 id=“counter”>708</h3>?

I have a site with counters, and has <h3 id="counter">0</h3> . How do I change the counter number? Where can I find it to change?

This is the code:

<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>

add the following to the 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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM