How to control the display mode of part of the content in the web page through buttons

at present, three display modes have been designed, style-grid, style-grid-2 and style-list-1, have been implemented statically, that is, the < section class= "video-listing style-list-1" > has been changed, but how to switch dynamically through js has not been adjusted well. I hope the master can give me advice. The website is developed using django. The related code is as follows:

                <section class="video-listing style-list-1">
                    <div class="video-listing-head">
                        <h2 class="light-title" style="color:-sharp000; margin-bottom:20px;"></h2>
                        <div class="video-listing-filter">
                            <ul id="myTab" class="nav nav-tabs">
                                <li class="active">
                                    <a href="-sharpnew" data-toggle="tab"></a>
                                </li>
                                <li>
                                    <a href="-sharpview" data-toggle="tab"></a>
                                </li>
                                <li>
                                    <a href="-sharpcomment" data-toggle="tab"></a>
                                </li>
                                <li>
                                    <a href="-sharpdownload" data-toggle="tab"></a>
                                </li>
                                <div class="pull-right style-filter hidden-xs">
                                    <a data-style="style-grid" class=""><i class="fa fa-th"></i></a>
                                    <a data-style="style-grid-2" class="" ><i class="fa fa-th-large"></i></a>
                                    <a data-style="style-list-1" class="current"><i class="fa fa-th-list"></i></a>
                                </div>
                            </ul>
                        </div>
Aug.03,2021

var styleone = document.querySelectorAll('.pull-right a')[0]
var styletwo = document.querySelectorAll('.pull-right a')[1]
var stylethree = document.querySelectorAll('.pull-right a')[2]
var section = document.querySelector('.video-listing')

styleone.onclick = function(e) {
  section.classList.remove('style-grid-2 style-list-1');
  section.classList.add('style-grid');
};
styletwo.onclick = function(e) {
  section.classList.remove('style-grid style-list-1');
  section.classList.add('style-grid-2');
};
stylethree.onclick = function(e) {
  section.classList.remove('style-grid style-grid-2');
  section.classList.add('style-list-1');
};

pay attention to browser compatibility with classList

Menu