Skip to content

Instantly share code, notes, and snippets.

@LucianoCharlesdeSouza
Last active August 24, 2019 10:10
Show Gist options
  • Select an option

  • Save LucianoCharlesdeSouza/4db51314e157ef254ce713e0e470bd4a to your computer and use it in GitHub Desktop.

Select an option

Save LucianoCharlesdeSouza/4db51314e157ef254ce713e0e470bd4a to your computer and use it in GitHub Desktop.
colapse
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
</head>
<body>
<div id="accordion">
<?php
$clients = [
['id' => 1, 'title' => 'Title 1', 'description' => '1 pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid.'],
['id' => 2, 'title' => 'Title 2', 'description' => '2 pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid.'],
['id' => 3, 'title' => 'Title 3', 'description' => '3 pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid.']
];
foreach($clients as $client){
?>
<div class="card">
<div class="card-header" id="heading<?php echo $client['id'];?>">
<h5 class="mb-0">
<button class="btn btn-link" data-toggle="collapse" data-target="#collapse<?php echo $client['id'];?>" aria-expanded="true" aria-controls="collapse<?php echo $client['id'];?>">Expandir</button>
</h5>
</div>
<div id="collapse<?php echo $client['id'];?>" class="collapse" aria-labelledby="heading<?php echo $client['id'];?>" data-parent="#accordion">
<div class="card-body">
<?php echo $client['description'];?>
</div>
</div>
</div>
<?php
}
?>
</div>
<script
src="https://code.jquery.com/jquery-3.4.1.min.js"
integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo="
crossorigin="anonymous"></script>
<script>
$('.btn-link').click(function(){
let text = $(this).text();
if(text === 'Expandir'){
$(this).text('Recolher');
}else{
$(this).text('Expandir');
}
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment