Demo of modulus function resetting incremental counter in JavaScript

<script>
var speed=1000; // For one second duration it is 1000
var counter_value=30; // change this value
var ms=0;
function my_function(){
document.getElementById("d1").innerHTML="<h2>"+ ms + "</h2>"; // display the counter
ms=ms+1; // increment by 1
if(ms % counter_value ==0){
ms=0;
}	
//timer to trigger my_function() at an interval of millseconds set by speed valirable//
my_time=setTimeout('my_function()',speed);
}
/////////
my_function();
</script>
Modulus Tutorial DEMO of changing alternate background colour by using Modulus
Subscribe to our YouTube Channel here


Subscribe

* indicates required
Subscribe to plus2net

    plus2net.com







    Post your comments , suggestion , error , requirements etc here




    We use cookies to improve your browsing experience. . Learn more
    HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
    ©2000-2024 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer