简体   繁体   English

手风琴动画Jquery

[英]Accordion animate Jquery

Hello I would want that #accordion if it is opened eliminates the margin of 200px, if it is closed inserts the margin of 200px. 您好,我希望#手风琴打开时消除200px的边距,如果关闭,则插入200px的边距。 I have connected elimination of the margin to the function on click h3, when it is opened. 当打开h3时,我已将消除边距连接到了该函数上。 How I make to insert the margin when #accordion is closed? #手风琴关闭时,我如何插入边距?

Link temporany page: http://www.davidxdesign.altervista.org/city.htm 链接临时页面: http ://www.davidxdesign.altervista.org/city.htm

<script>
 $(function() {
 var stop = false;
 $("#accordion h3").click(function( event ){
 if ( stop )
{ event.stopImmediatePropagation();
 event.preventDefault(); stop = false } });
 $("#accordion").accordion({ 
header: "> div > h3",
 collapsible: true,
 active: false, 
autoHeight: false, 
changestart: function(event, ui){ ui.newHeader.parent().prependTo(this); } })
 .sortable({ 
axis: "y", 
handle: "h3", 
stop: function() { stop = true; } }) }); 
</script>
 <script> 
function zeromargindiv(){
 $('#accordion').animate({ 
marginTop: '0px' },
 2000, function() { }); } 
</script>**


<div id="accordion" style="margin-top:180px">

<div class="group">
    <h3  onclick="zeromargindiv()">Cosa Visitare</h3>
    <div>
   </br> 
<a onclick="go('map/duomo.htm')">Via del Duomo</a>  </br>
<a onclick="go('map/cavour.htm')">Corso Cavour</a>  </br>
<a onclick="go('map/palcapitano.htm')">Palazzo del Capitano del Popolo</a>  </br>
<a >Palazzo Comunale</a>  </br>
<a >Vicolo degli Artisti</a>  </br>
<a href="http://www.baduel.it" target="_blank"   >Libreria antiquaria Baduel</a>  </br>
<a href="http://www.bibliotecaorvieto.it/easyne2/LYT.aspx?IDLYT=8892&ST=SQL&SQL=ID_Documento=30&CODE=FUMI" target="_blank" >Biblioteca Fiumi</a>  </br></br>

 </div>
  </div> 
etc...

Try this out:- http://jsfiddle.net/adiioo7/HpeM4/2/ 试试看: -http : //jsfiddle.net/adiioo7/HpeM4/2/

JS:- JS:-

$(function () {
    var stop = false;
    $("#accordion h3").click(function (event) {
        if (stop) {
            event.stopImmediatePropagation();
            event.preventDefault();
            stop = false;

        }
    });
    $("#accordion").accordion({
        header: "> div > h3",
        collapsible: true,
        active: false,
        autoHeight: false,
        changestart: function (event, ui) {
            ui.newHeader.parent().prependTo(this);
        },
        activate: function (event, ui) {
            if ($("#accordion").accordion("option", "active") === false) {

                $('#accordion').animate({
                    marginTop: '180px'
                },
                2000, function () {});
            }
        }

    })
        .sortable({
        axis: "y",
        handle: "h3",
        stop: function () {
            stop = true;
        }
    })
});

function zeromargindiv() {
    if ($("#accordion").accordion("option", "active") === false) {

        $('#accordion').animate({
            marginTop: '0px'
        },
        2000, function () {});
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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