这次下拉失败有什么明显的原因吗?

时间:2017-02-02 22:28:04

标签: javascript jquery html css

我有一个可扩展/可折叠的菜单,当您点击<span>它会显示并展开<div>时,我按照教程逐字复制并粘贴代码,但它没有似乎工作。我错过了一些非常明显的东西吗?

$(".header").click(function() {

  $header = $(this);
  //getting the next element
  $content = $header.next();
  //open up the content needed - toggle the slide- if visible, slide up, if not slidedown.
  $content.slideToggle(500, function() {
    //execute this after slideToggle is done
    //change text of header based on visibility of content div
    $header.text(function() {
      //change text based on condition
      return $content.is(":visible") ? "Collapse" : "Expand";
    });
  });
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="container">
  <div class="header"><span>Expected Outcomes of a Corporate Course</span>
  </div>
  <div class="content">
    <ul>
      <li>A better relationship with your coworkers.</li>
      <li>A High Trust and open enivornment.</li>
      <li>A safe and fun environment to work in.</li>
    </ul>
  </div>
</div>

0 个答案:

没有答案