繁体   English   中英

如何使用 php 获得切换按钮

[英]How do I get toggle button working with php

引导切换按钮似乎拒绝与 php 一起使用。

见代码

<div style="width:100%; height:auto; padding:10px 0; background:#0F71BA; font-family:Verdana; color:#fff;" onclick="toggleDept()">
        <span style="margin-left:10px;"> Select Department  </span>
        <i class="fa-chevron-down fa" style="float:right; margin-right:10px; cursor:pointer"></i>
</div>
<div style="width:100%; background:#fff; height:400px; overflow:auto; display:none" id="dept-sub-list-mobile">
        <?php...

单击移动模式下的部门下拉菜单以了解问题

您在页面上没有toggleDept javascript function; 将以下代码添加到您的 javascript 文件中

function toggleDept(){ 
    $('#dept-sub-list-mobile').toggle(); 
}

在 javascript 你可以这样做: -

 function toggleDept(){ 
    var x = document.getElementById("dept-sub-list-mobile");
      if (x.style.display === "none") {
        x.style.display = "block";
      } else {
        x.style.display = "none";
      }
    }

您必须在页面上添加toggleDept() function javascript function。 对于切换功能,我们使用jQuery toggle()方法。 这是代码:

function toggleDept(){ 
    $('#dept-sub-list-mobile').toggle(); 
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM