0
我需要一个针对我的网站的内容过滤系统。通过检查和取消选中复选框,相应的元素应该显示或隐藏。上述php javascript过滤内容
<form>
<p><input type="checkbox" checked="checked"><label>Plants</label></p>
<p><input type="checkbox" checked="checked"><label>Animals</label></p>
<p><input type="checkbox" checked="checked"><label>Humans</label></p>
</form>
的复选框应触发下面与根据类的div的可见性,通过改变display:block;
到display:none;
<div class="Plants" style="display:block">
<p>Grass</p>
<div>
<div class="Humans" style="display:block">
<p>John</p>
<div>
<div class="Plants" style="display:block">
<p>Flower</p>
<div>
<div class="Animals" style="display:block">
<p>Lion</p>
<div>
例如: 通过uchecking的植物复选框,与草和的div花应该隐藏起来。
什么是最优雅的方式来完成在PHP或JavaScript?
因为我是很新的脚本,你能解释一下这是如何工作,以及如何这个片段可以在PHP中实施,请。 –
@GabrielWinkler我更新了答案。我希望这可以帮助你。 – gaetanoM