I have this toggle function to make a list item visible and invisible. Without the variable id it works (only the first one opens of course). But with the variable it doesn't work at all. The variable is just a number, added to the list item id, which is well shown in the html code. This is the function that I have:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script>
$("#button-" . $row['id'] . "").click(function() {
$("#bands-" . $row['id'] . "").toggle();
});
</script>
<?php
echo "<a id='button-" . $row['id'] . "'>bands</a>";
echo "<li id='bands-" . $row['id'] . "' class='clearfix list-group-item' style='display: none;'></li>";
?>
( to echo each line is a bit ugly, I know, but it works :-P )