How to repeat a code in html without writing the same code again and again
Have a look at server side includes
Include it like this in your page :
<?php include ('content.html'); ?>
Here is simple JavaScript code to repeat text: (which can be modified as per requirement may be to insert innerHTML
)
function repeat(n,Txt){
for(i=0; i<n;i++)
document.write(Txt+ char(13)); //char(13) to draw new line
}
Just call this function as per requirement, on window.Load
or onclick
of a button..
Update: Check this fiddle to Enter repeating HTML fiddle
Code for innerHTML:
function repeat(n,Txt){
for(i=0; i<n;i++){
document.getElementById("repeater").innerHTML =
document.getElementById("repeater").innerHTML + "<br /> "
+ Txt;
}
}