折叠-默认情况下打开的手风琴第一个元素

时间:2019-05-20 09:06:04

标签: javascript jquery accordion

我正在与Collapse“ Accordion”合作。当我的页面加载时,默认情况下默认打开第一个折叠,请提出默认关闭它的方法!

感谢您的帮助。感谢您的帮助!

<link href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css" rel="stylesheet"></link>
<link href="/resources/demos/style.css" rel="stylesheet"></link>

<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>

<div id="accordion">
  <h3>
    Click Here for answer:)</h3>
  <div style color: "red;">
    <b>Answer: </b>206 Bones
  </div>
</div>


<script>
  $(function() {
    $("#accordion").accordion({
      collapsible: true
    });
  });
</script>

3 个答案:

答案 0 :(得分:1)

请使用这个。

var result = (from root in context.Roots.Include(x => x.Children)
          from child in root.Children
          where child.Code == "A100"
          select new
          {
              Id = root.Id,
              Children = child
          }).ToList();

答案 1 :(得分:-1)

您必须使用此属性:

  active: false

遵循一个工作示例:

<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />

</head>
<body>
<link href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css" rel="stylesheet"></link>
  <link href="/resources/demos/style.css" rel="stylesheet"></link>
<div id="accordion">
<h3>
Click Here for answer:)</h3>
<div style color:"red;">
<b>Answer: </b>206 Bones
  </div></div>

<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
  <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
  <script>
  $( function() {
    $( "#accordion" ).accordion({
 collapsible: true,
       active: false
    });
  } );
  </script>
</body>
</html>

答案 2 :(得分:-1)

这可以解决问题

$(“#accordion”)。accordion({         可折叠:是的,         活动:错误     });