简体   繁体   中英

Collapse Expand in jquery

I am trying to expand and collapse the content in jquery. But the toggle responding reversely. When I expanding, it is showing the content from bottom to top and when I collapsing, it is showing the content from top to bottom. And also, when it is expanding, I want the image also to come right of the content. and when I collapsing, it should collapse and set it to top.

Before:

在此处输入图片说明

I need like this:

在此处输入图片说明

Here is what I tried.

 ons.bootstrap(); $(document).ready(function() { $(".header").click(function() { $(".content").slideToggle(); }); }); 
 <link href="http://components.onsen.io/onsen-css-components-default.css" rel="stylesheet" /> <link href="http://components.onsen.io/patterns/lib/onsen/css/onsenui.css" rel="stylesheet" /> <script src="http://components.onsen.io/patterns/lib/onsen/js/angular/angular.js"></script> <script src="http://components.onsen.io/patterns/lib/onsen/js/onsenui.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <ons-list-item style="min-height: 20px; line-height: 20px;" class="list__item ons-list-item-inner"> <div style="cursor:pointer; margin-left: 291px;" class="header"> <ons-icon style="font-size: 23px; font-weight: bold; color: #000000; width: 1em" icon="ion-navicon" class="ons-icon ion-more ons-icon--ion ons-icon--fw fa-lg"></ons-icon> </div> <div style="margin-left: 12px; margin-top: -15px; display: block;" class="content"> <span style="font-family: Arial; font-size: 14px; color: #666666;">Content 1<br>content 2</span> </div> </ons-list-item> 

如果要实现该效果,.content div应该以display:none开头。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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