html - xhtml 停止加载 div
问题描述
我是 html、java 脚本和 css 的新手,我正在为 U 开发一个项目,我有疑问。我正在制作一个个人资料页面,根据用户类型,它应该显示特定信息。为此,我使用标签 div 来隐藏实体 Profile 不应该拥有的数据,因为它没有这些属性。换句话说,我有超类“个人资料”和子类“自由职业者”和“客户”。自由职业者具有“cumplimiento”属性,而“cliente”则没有。
<div id="pfreelance" style="display: none">
<h:outputLabel for="cumplitud" value="Score:"
styleClass="control-label" />
<p:inputText autocomplete="off" id="cumplitud"
styleClass="form-control" style="margin: 0px 0px 10px 0px"
value="#{perfilPageController.profile.cumplimiento}" maxlength="50"
required="true" />
</div>
<div id="pcliente" style="display: none">
<p>you are in page of Cliente</p>
</div>
<script type="text/javascript">
var pf = document.getElementById("pfreelance");
var pc = document.getElementById("pcliente");
if ("#{perfilPageController.Bottom()}" == "c"){
pc.style.display = "inline";
}
else if ("#{perfilPageController.Bottom()}" == "f"){
pf.style.display = "inline";
}
</script>
我尝试使用 style.display = "hidden" bt 这只是使 div 不可见,但不会阻止它加载。我知道我可能会犯很多错误,但我想知道是否有办法阻止 id 为“pfreelance”的 div 加载。如果您对我应该如何修复我的代码有任何建议?, 我会很感激。
解决方案
推荐阅读
- mysql - 使用 mysql 的 Node.JS ER_PARSE_ERROR
- java - 在 EDT 中运行时显示 JFreeChart 点的性能问题
- javascript - 将数组数据转换为对象
- python-3.x - Python TCP数据包变得混合
- django - django - modelforms 和 react - DRY
- android - Android - 如何在 kotlin 的房间数据库中预填充数据(更新)?
- python - 如何将 Pandas Dataframe 转换为 Numpy 数组
- assembly - Venus RISC-V 如何循环、比较和打印?
- python - 是否可以创建一个可以由用户在 python 中编辑的表。即用户名和密码框
- api - 我的 WebService 登录的 URL 等效项是什么