Reputation: 1
I want to use an incremental div id, so that all my id are unique, therefore I can use jquery effects to modify them independently.
I hope my question makes sense. If i need to elaborate please let me know.
div id ="name_$id"
Ok maybe I have to be more clear about my question.
Here are two divs with same id.
<div id="comment">
</div>
<div id="comment">
</div>
I want the id of the two divs to be comment1, and comment2. But automatically.
So I know I will need for example , $i to accompany comment, like comment_$i
I also know that I will have to increment i++ after each div displayed.
I hope I am more clear.
Upvotes: 0
Views: 8268
Reputation: 1
No worries, I found a great tutorial on http://www.adipalaz.com/experiments/jquery/expand.html
It was the expand/collapse all that i was after.
Thanks maate
Upvotes: 0
Reputation: 42350
something like this? You're question isn't very clear, but you can use a loop and give unique ids like so:
for($i=0;$i < 10;$i++;) {
echo "<div id='idhere_$i'>";
echo "stuff in the div";
echo "</div>
}
Upvotes: 2
Reputation: 54242
Sounds like you already have it.
As a loop:
<?php
for($i = 0; $i < $some_max_value; $i++){
echo "<div id=\"name_$id\">stuff</div>";
}
?>
Upvotes: 0