expand all and collapse all feature does not function completely

expand all and collapse all feature does not function completely

I have an issue with my expand all/collapse all feature.

Here is my jsfidde link:


Lets say expand Name1 and Name2 and then hit Expand all button, What it does is it expands everything but collapses Name1 and Name2.

Do I specify the css id in my javascript function?

$(function () {
    $(document).on('click', '.expandcollapse', function (e) {

        $('.collapse').each(function (index) {
            $(this).collapse("toggle");
        });

        if ($(this).is('.icon.white-icon .iconplus-sign')) {
            $(this).toggleClass('is-collapsed');
        } else {
            $(this).toggleClass('is-collapsed');

        }
    });
});