I have a simple open() function to trigger a hidden div by an id, and display block the content:
function open() {
var x = document.getElementById("open");
if (x.style.display === "none") {
x.style.display = "block";
} else {
x.style.display = "none";
}
}
@foreach($users as $user)
<div class="button" onclick="open()">
<h4>+</p>
</div>
<div id="open">
<h4>{{$user->name}}</p>
</div>
@endforeach
Logically this only works for one element (the first) in a foreach loop. How can I make my method more dynamic, so that if I have a collection of e.g. 5 elements - I can open each element separately?
@bobbybouwmann - Yes, I knew that was the problem, but couldn't find a workaround. Actually stepped over your link before opening the question - but it was a bit unclear then.