【问题标题】:Show/Hide jQuery menu显示/隐藏 jQuery 菜单
【发布时间】:2012-09-18 04:54:58
【问题描述】:

我想要我的网站的显示/隐藏菜单。

当您单击站点底部的"Partners" 时,我希望它能够像www.nicolaspopupshop.com 上的那样运行。

我一整天都在尝试这样做,但我对它的工作原理感到非常困惑。

我很擅长 HTML,但是一旦 javascript 发挥作用,我就一无所知。我想这对专家来说是一个烦人的问题,但如果有人能帮助我,这对我来说意味着世界。

谢谢!

这是我在样式标签中的内容:



#footer .bottom #partners_trigger {
      cursor: pointer;
      margin-left: 170px; }
    #footer .bottom #partner_list {
      width: 320px;}
    #footer .bottom #partner_list ul {
      position: fixed;
      text-align:center;
      font-size:11px;
      text-transform: uppercase;
      bottom: 40px;
      left: 50%;
      width: 320px;
      margin: 0 0 0 -160px;
      background: #FA9313;
      background: rgba(250, 147, 19, 0.85);
      padding: 10px 0;
      -webkit-border-radius: 6px;
      -moz-border-radius: 6px;
      border-radius: 6px;
      z-index: 300;
      line-height: 18px;
      display: none; }
      #footer .bottom #partner_list ul a {
        color: white; 
        font-family: Arial, Helvetica;}
      #footer .bottom #partner_list ul a:hover {
        color: #e9118c; }
      #footer .bottom #partner_list ul.active {
        display: block; }

我尝试将我拥有的内容放入 body 标记中,但无法正常显示。

【问题讨论】:

  • 你到现在为止的尝试。只需发布一些代码。
  • 老兄,忘记css。发布您的 html 和 javascript。

标签: javascript jquery html show-hide


【解决方案1】:
$(document).ready(function() {
    var $list = $("#your-ul");
    $("#your-toggle-link").bind('click', function() {
       $list.slideToggle();
    })
});

【讨论】:

  • 谢谢,但它仍然不适合我。我在我的问题中添加了我的样式标签中的内容,我认为这不会有太大帮助,但如果你能看一下并提出一些建议,这对我来说意义重大。
【解决方案2】:

首先创建一个 div 并将其样式设置为 display:none。我假设您的合作伙伴链接有一个 ID 合作伙伴 然后在下面写代码

$(document).ready(function() {
    $("#Partners").bind('click', function() {
      $("#your_div").slideToggle(); //your_div is the id of the div with display none
    })
});

【讨论】:

  • 非常感谢,但它仍然不适合我。我将我的样式标签中的代码添加到我的问题中,不确定这是否会有所帮助。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2015-03-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多