Skip to content Skip to sidebar Skip to footer

How Do I Make This Javascript In Loop?

Sorry, I'm new in Javascript. I don't know how to make this looping in Javascript. This is my fiddle, that is so ugly because there's no loop there. I made it in PHP, but i don't k

Solution 1:

This is your PHP-loop in javascript. Pretty much the same... Just remember to use the <script> javascript code here </script> tag to tell the browser that this is javascript

for (a = 1; a < 2; a++) { 
    //Your stuff inside here
}

To append HTML to a div you can use the following code:

document.getElementById('divID').innerHTML = '<p>your data here</p>';

Or if you include Jquery as well it can be done even simpler:

$('#divID').append('<p> your data here </p>');

Solution 2:

In Javascript:

for(var a = 1; a <= 2; a++){
        // do stufffor(var b = 1; b <= a; b++){
            // do stuff
        }
//do stuff
}

Post a Comment for "How Do I Make This Javascript In Loop?"