Skip to main content
2 of 2
Magento2 - How to change product view Grid or List without reload page?

Magento2 - How to change product view Grid or List without reload page?

I have search many hours to accomplish this but not get success to achieve last I tried Stack overflow link

and also add my custom jQuery in list.phtml file

<script>
    require(['jquery'], function ($) {
        jQuery(document).ready(function () {
            $(".mode-grid").click(function () {
                    alert('call Grid');
                    $('.mode-grid').addClass('active');
                    $('.mode-list').removeClass('active');

                }
            );
            $(".mode-list").click(function () {
                alert('call List');
                $('.mode-list').addClass('mode-list active');
                $('.mode-grid').removeClass('mode-grid active');
            });
        });
    });
</script>

but not get success, please help me to solve this ,I am new in Magento so also inform me where I make mistakes.

Thank you.