I have a div element inside while (mysql query). So for every entry I want id to increment by 1. If I have "div id="0"" initially, with every new object I want id++. I have no idea how to do it and tried something like this:
<?php //some code
for ($i = 0; $i < $sent+1; $i++) {
?><script>jQuery(".list-row").attr("id", "$i")</script> <?php //some code
.list row is a class of div element. Any ideas how to do it in right way?
This would do it for you
<?php //some code
for ($i = 0; $i < $sent+1; $i++) {
echo '<script>jQuery(".list-row").attr("id", "' . $i . '")</script>';
}
Or maybe this would be better and more readable later
<?php //some code
for ($i = 0; $i < $sent+1; $i++) {
echo '<script>jQuery(".list-row").attr("id", "sent_' . $i . '")</script>';
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.