For Loop
For Loop
by Nirvanachain
HTML
<p>Click on the button to generate a random number that is between 1 and 10</p>
<p><input type="button" name="myButton" value="Click Here" onClick="myClickFunction()"></p>
<p class="myCount"></p>
<p>The number is <span class="myText"></span></p>
CSS
p {
margin:0 10px 20px 20px;
}
p:first-child {
margin:20px 10px 20px 20px;
}
JavaScript
function myClickFunction() {
var result = Math.round(Math.random()*10);
for (x = 0; x < result; x++) {
$(".myCount").html( $(".myCount").html() + "<br />" + x );
}
$(".myText").text(result);
}