javascript - Add new id to each div that contains the same class -
i'm looking see how can take div have same class , add together , id increment each new id count number illustration default html this.
<div id="content"> <div class="section"></div> <div class="section"></div> <div class="section"></div> <div class="section"></div> </div> what able auto add together id called id="section-1" , each div add together 1 sec div id="section-2"
so output like
<div id="content"> <div id="section-1" class="section"></div> <div id="section-2" class="section"></div> <div id="section-3" class="section"></div> <div id="section-4" class="section"></div> </div> i'm not sure if can php thinking
$variable = way add together +1 each div <div id="section-<?php echo $variable ?>" class="section"></div> i may way off on how i'm going help appreciated. give thanks you.
not sure,but can assign id's
for($i=1;$i<=$your_posts_value;$i++) { ?> <div id="section-<?=$i ?>" class="section">test</div> <?php } javascript php html
No comments:
Post a Comment