The essence of the problem is as follows: there is something like a menu, and there are sub-items in the form of buttons. I want to make these sub-items disappear if the screen is less than 767px (otherwise, the buttons become a random column), and when I clicked on a menu item, they opened. The buttons themselves also have links in the form of lists that are hidden and that open when you click these buttons. This item works fine, but with the first trouble - I do not get any response to the click. On jQuery, I got the following code:
'$( window ).resize(function() { if($(window).width() <=767) $('.list-tenses').click(function(){ $('.open-list_tenses').slideToggle(); }); });' I hope, clearly explained the point, I hope for your advice! In JQuery, I am just starting to work, so I will accept any constructive criticism and remember how it should be. The rest of the code looks like this (on media querries display: none of the sub-items, of course):
function openListPerfect() { var list = document.getElementById("openListPerfect"); if (list.style.display == "block") { list.style.display = "none"; } else { list.style.display = "block"; } } function openListSimple() { var list = document.getElementById("openListSimple"); if (list.style.display == "block") { list.style.display = "none"; } else { list.style.display = "block"; } } .hidden-links { display: none; } <div class="row justify-content-center"> <div class="col-md-3"> <div class="title-groups open-list_tenses"> <h5>Tenses</h5> </div> </div> </div> <div class="row justify-content-center"> <div class="col-md-3"> <h5 id="list" onclick="openListSimple()" class="btn btn-outline-secondary list-tenses">Present Simple</h5> </div> <div class="col-md-3"> <h5 id="list" onclick="openListPerfect()" class="btn btn-outline-secondary list-tenses">Present Perfect</h5> </div> </div> <div class="row justify-content-center"> <div class="col-md-3"> <ul class="hidden-links list-unstyled" id="openListSimple"> <li class="hidden-links_list"><a href="https://www.instagram.com/p/BRSLQPehUg7/?hl=ru&taken-by=thepalms.blog" target="_blank" class="blog-links">Rules and Myths Part 1</a></li> <li class="hidden-links_list"><a href="https://www.instagram.com/p/BRUwQ5-h2Gh/?hl=ru&taken-by=thepalms.blog" target="_blank" class="blog-links">Rules and Myths Part 2</a></li> </ul> </div> </div> <div class="row justify-content-center"> <div class="col-md-3"> <ul class="hidden-links list-unstyled" id="openListPerfect"> <li class="hidden-links_list"><a href="https://www.instagram.com/p/BdpnOmChaLI/?hl=ru&taken-by=thepalms.blog" target="_blank" class="blog-links">Rules</a></li> <li class="hidden-links_list"><a href="https://www.instagram.com/p/BhDoUDrh3Ve/?hl=ru&taken-by=thepalms.blog" target="_blank" class="blog-links">Present Perfect (all cases)</a></li> <li class="hidden-links_list"><a href="https://www.instagram.com/p/BfgHErbBjN8/?hl=ru&taken-by=thepalms.blog" target="_blank" class="blog-links">Experience</a></li> <li class="hidden-links_list"><a href="https://www.instagram.com/p/Be11EY8hyPJ/?hl=ru&taken-by=thepalms.blog" target="_blank" class="blog-links">Always/Never</a></li> </ul> </div> </div>