2013-02-10 4 views

답변

1

http://jsfiddle.net/v6URL/1/

$(".collapsible.scroll legend").click(function (e) { 
    e.preventDefault(); 
    smoothScrollTo(this); 
}); 

function smoothScrollTo(element) { 
    var thisTop = $($(element).parent()).offset().top; 
    $("html, body").animate({ 
     scrollTop: thisTop + "px" 
    }, { 
     duration: 600 
    }); 
    return false; 
}; 

$(document).ready(function() { 
    $(".collapsible .collapsed").hide(); 
    $(".collapsible legend").html(function() { 
     var scroll = $(this).parent().hasClass('scroll'); 
     if (scroll == true) { 
      href = "#" + $(this).parent().attr('id'); 
     } else { 
      href = "javascript:void(0)"; 
     }; 
     return '<a href="' + href + '">' + $(this).html() + '</a>'; 
    }).click(function() { 
     $(this).parent().children('.content').slideToggle(); 
    }); 
    $(".collapsible.scroll legend").click(function() { 
     smoothScrollTo(this); 
    }); 

}); 

나는 해결책을 발견