首页 > 解决方案 > 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 加载。如果您对我应该如何修复我的代码有任何建议?, 我会很感激。

标签: htmljsf

解决方案


推荐阅读