How can I get my accordion script to be closed when the page loads? My script is this:
$('[data-fn="accordion"]').on('click',function(e) {
var id = $(this).data('open');
$('#'+id).slideToggle();
if(!$(this).children('.icon-arrow').hasClass('open')) {
$(this)
.children('.icon-arrow')
.addClass('open')
.removeClass('close');
e.preventDefault();
}
else {
$(this)
.children('.icon-arrow')
.removeClass('open')
.addClass('close');
e.preventDefault();
}
});
And here is the JSFiddle
Thanks, regards Thomas