There is a piece of code, roughly as follows:
Pure HTML can't do it
There are three ideas for using js.
One is document.write
Two is innerHTML
Three is createElement
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script><script type="text/javascript"> $(function(){ $("#abv").click(function(){ for(var i=1;i<=$("div").length-1;i++){ $("#div"+i).html(i); } }); })</script><input type="button" id="abv" value="测试用按钮"/><div id="kkk"> <div id="div1" class="class1">`````</div> <div id="div2" class="class2">`````</div> <div id="div3" class="class3">`````</div></div>
1. Use descendant code to implement
whether it is asp. Net/asp/jsp all have for loops. The advantage of this is that even if the client does not support js, it can still display DIV
2. Use js to implement
for(var i=1;i<=10; i ){
$('
for(var i=1;i<=10;i ){
$('