Zambo107 Posted August 24, 2020 Share Posted August 24, 2020 Site URL: https://www.diabeticexchangeusa.com/price-list On the mobile view I would like for the category selector to be a drop down menu rather than what it is as default. Link to comment
tuanphan Posted August 24, 2020 Share Posted August 24, 2020 Add to Home > Settings > Advanced > Code Injection > Header <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.0/jquery.min.js"></script> <script> $(document).ready(function(){ if (jQuery(window).width() <= 767) { $(document).ready(function() { var catItem = $('a.category-filter-link'); var itemTag = $(catItem).html(); var catDrop = "<select name='Categories' id='categories' class='catDrop'>"; if (itemTag !== undefined) { catItem.each(function(i) { var fixLoc = $(this).html().trim().replace(/\s+/g, '+').replace(/&/g, '%26').replace('amp;', ''); catDrop = catDrop + '<option value=' + fixLoc + '>' + $(this).html() + '</option>'; i++; }); catDrop = catDrop + "</select>"; $(catDrop).insertAfter($('.category-filter-wrapper')); } var urlCat = window.location.href.split("?category=")[1]; if (urlCat !== undefined) { var fixCat = urlCat.replace(/\%27/g, "'") $(".catDrop").val(fixCat); } $(".catDrop").change(function() { if ($(this).val() == "All") { window.location = "/"; } else { window.location = "?category=" + $(this).val(); } }); }); } }); </script> <style> @media screen and (max-width:767px) { nav.category-filter-wrapper { display: none; } } </style> then save & refresh your site. Code by @rwp Email me if you have need any help (free, of course.). Answer within 24 hours. Or send to forum message Contact Customer Care - Learn CSS - Buy me a coffee (thank you!) Link to comment
sharine Posted January 8, 2021 Share Posted January 8, 2021 On 8/24/2020 at 5:00 PM, tuanphan said: Add to Home > Settings > Advanced > Code Injection > Header <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.0/jquery.min.js"></script> <script> $(document).ready(function(){ if (jQuery(window).width() <= 767) { $(document).ready(function() { var catItem = $('a.category-filter-link'); var itemTag = $(catItem).html(); var catDrop = "<select name='Categories' id='categories' class='catDrop'>"; if (itemTag !== undefined) { catItem.each(function(i) { var fixLoc = $(this).html().trim().replace(/\s+/g, '+').replace(/&/g, '%26').replace('amp;', ''); catDrop = catDrop + '<option value=' + fixLoc + '>' + $(this).html() + '</option>'; i++; }); catDrop = catDrop + "</select>"; $(catDrop).insertAfter($('.category-filter-wrapper')); } var urlCat = window.location.href.split("?category=")[1]; if (urlCat !== undefined) { var fixCat = urlCat.replace(/\%27/g, "'") $(".catDrop").val(fixCat); } $(".catDrop").change(function() { if ($(this).val() == "All") { window.location = "/"; } else { window.location = "?category=" + $(this).val(); } }); }); } }); </script> <style> @media screen and (max-width:767px) { nav.category-filter-wrapper { display: none; } } </style> then save & refresh your site. Code by @rwp Hey, Can I get help with this? Should I send an email? Link to comment
tuanphan Posted January 10, 2021 Share Posted January 10, 2021 On 1/8/2021 at 11:30 PM, sharine said: Hey, Can I get help with this? Should I send an email? You can send an email if you want. Above code doesn't work? Email me if you have need any help (free, of course.). Answer within 24 hours. Or send to forum message Contact Customer Care - Learn CSS - Buy me a coffee (thank you!) Link to comment
sharine Posted January 11, 2021 Share Posted January 11, 2021 On 1/10/2021 at 4:17 AM, tuanphan said: You can send an email if you want. Above code doesn't work? No, it doesn't unfortunately. Link to comment
tuanphan Posted January 11, 2021 Share Posted January 11, 2021 2 hours ago, sharine said: No, it doesn't unfortunately. try contacting @rwp Can you share your site url? Email me if you have need any help (free, of course.). Answer within 24 hours. Or send to forum message Contact Customer Care - Learn CSS - Buy me a coffee (thank you!) Link to comment
Recommended Posts
Archived
This topic is now archived and is closed to further replies.