jQuery Accordion: IE animation issues

后端 未结 16 1630
我寻月下人不归
我寻月下人不归 2020-12-25 14:39

Update

I am making this a community wiki, for three reasons:

  • I don\'t feel like I got a definitive answer, but
  • I have long since stopped nee
16条回答
  •  悲哀的现实
    2020-12-25 15:08

    I've actually avoided using the accordion plugin as I found it a little bit inflexible for my needs. I've found that the easiest and most flexible accordion is as simple as:

    var accordion = function(toggleEl, accEl) {
        toggleEl.click(function() {
            accEl.slideToggle(function() { });
            return false;
        });
    }
    

    for your example you would use it like this:

    $(document).ready(function() {
        new accordion($("a.accordion-label"), $("ul. linklist"));        
    });
    

    you can use this as a template and build in css class adding, callbacks and other useful stuff, but I've found that in the end it was much easier to do it this way than to dick around with the accordion plugin.

    EDIT: Sample code with a callback function

    var accordion = function(toggleEl, accEl, callback) {
        toggleEl.click(function() {
            accEl.slideToggle(callback);
            return false;
        });
    }
    
    $(document).ready(function() {
        new accordion($("a.accordion-label"), $("ul. linklist"), function() { /* some callback */ });        
    });
    

提交回复
热议问题