在bootstrap中折叠元素

时间:2013-04-19 04:48:07

标签: javascript jquery css twitter-bootstrap

<div >
 <div>
  <h3 style="display:inline-block;">Comments</h3>
  <button id="add_button" style="display:inline-block;margin-left:240px;" type="button" class="btn btn-primary" onClick="$('#add_button').hide()" data-toggle="collapse" data-target="#comments">Add</button>
 </div>
 <div id="comments" class="collapse in">
  <textarea style="resize:none;width:90%;" class="input xlarge" rows="4" id="comment-box" name="comment-box" placeholder="Type your comment here..."></textarea>
  <button style="margin-right:30px;" id="submit_comment" class="btn btn-primary pull-right" name="submit_comment" type="submit" onClick="">Submit</button>
 </div>
</div>

所以这是我的代码。我有一个来自bootstrap的可折叠元素,我试图让它在页面中开始折叠,但我尝试了多种不同的方法。我已经使用了一些jQuery命令,比如 hide()并崩溃,但它们似乎都没有用。关于如何使其发挥作用的任何想法?

1 个答案:

答案 0 :(得分:0)

只需从我在此JSFiddle中显示的in div中删除id='comments'类,就可以在单击add按钮时显示注释textarea:

http://jsfiddle.net/JHkHE/1/