我想在我的php中做出这种崩溃。这是一个例子:
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<a data-toggle="collapse" href="#collapse1">Heading</a>
<div id="collapse1">
<a data-toggle="collapse" href="#collapse2">
Category
</a>
</div>
<div id="collapse2">Items</div>
&#13;
我想在这里应用类似的东西:
<?php
$i=1;foreach($itemlist as $value) {
echo "<h3>Tower Type : ".$value['notower']."</h3><br>";
foreach($value['items'] as $val) { ?>
<?= "<h4>".$val['groupem']."</h4><br>"; ?>
<table class ="table table-bordered table-hovered table-striped table-condensed">
<thead>
<th><?= "Item Name" ?></th>
<th><?= "Value" ?>
</thead>
<tbody>
<?php foreach($val['item'] as $v) :?>
<tr>
<td><?= $v['nm_detailem']?></td>
<td><?= $v['em_value']?></td>
</tr>
<?php endforeach;?>
</tbody>
</table>
<?php } ?>
<?php } ?>
我该怎么做?我被困在那些放置href
的地方。
答案 0 :(得分:0)
您可以使用以下内容:
$sOutput = '';
foreach ( $aData as $sData){
If($sOutput != ''){
$sOutput .= '</div><div class="collapse hidden">';
}
$sOutput .= '<a href=""></a>';
}
If(count($sOutput) == 1 && $sOutput !== ''){$sOutput .= '</div>';}
添加到css:
.hidden{display:none;}
你的jQuery可能是:
$(".collapse").on('click', function(){
$('.collapse').addClass('hidden');
$(this).removeClass('hidden');
});