在一个php include中显示certian div,在另一个php中显示所有div

发布时间:2022-04-30 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了在一个php include中显示certian div,在另一个php中显示所有div脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
我有一些内容存储在PHP文件中,我想在我的页面上包含两个地方.
首先,我想要包含所有内容,但在第二位,我只想在给定类的某些div中包含内容.

例如,我有以下文件

index.PHP
content.PHP
list.PHP
problems.PHP

index.PHP具有以下内容:<?PHP include“list.PHP”;包括“problems.PHP”; ?取代. list.PHPand problems.PHPcontains< PHP include“content.PHP”; ?> content.PHPhave以下内容

<div class="up">This location is up</div>
<div class="down">This location is down</div>

如何使用list.PHP显示content.PHP的所有内容,并且只在problems.PHP显示div class =“down”的内容

我试着补充一下

<style>
.up {display:none}
</style>

在problems.PHP中,但这从两个include中删除了所有div class =“up”.

谢谢!

解决方法

您可以使用id来区分

在problems.PHP

<div id='problems'><PHP include "content.PHP"; ?></div>
<style>
   #problems .up {display:none}
</style>

脚本宝典总结

以上是脚本宝典为你收集整理的在一个php include中显示certian div,在另一个php中显示所有div全部内容,希望文章能够帮你解决在一个php include中显示certian div,在另一个php中显示所有div所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签: