lindz5223 Posted February 26 Share Posted February 26 (edited) Hi All, I've found some codes to show/hide buttons {block IDs) on specific dates. I thought I had it all figured out, but they aren't displaying on mobile. Here are the codes I am using... <!-- Enrollment Dates --> <script> $(document).ready(() => { // MM - DD - YYYY function getDayFromDate(dateString) { var now = new Date(dateString); var start = new Date(now.getFullYear(), 0, 0); var diff = now - start; var oneDay = 1000 * 60 * 60 * 24; return Math.floor(diff / oneDay); } let cutoffLow = getDayFromDate("02/26"); let cutoffHigh = getDayFromDate("03/04"); let now = getDayFromDate(new Date()); if(now > cutoffLow && now < cutoffHigh) { document.querySelector('#block-yui_3_17_2_1_1696875352874_12959').style.display = ""; } else{ document.querySelector('#block-yui_3_17_2_1_1696875352874_12959').style.display = "none"; } }); </script> <!-- Waitlist Dates --> <script> $(document).ready(() => { // MM - DD - YYYY function getDayFromDate(dateString) { var now = new Date(dateString); var start = new Date(now.getFullYear(), 0, 0); var diff = now - start; var oneDay = 1000 * 60 * 60 * 24; return Math.floor(diff / oneDay); } let cutoffLow = getDayFromDate("02/05"); let cutoffHigh = getDayFromDate("02/25"); let now = getDayFromDate(new Date()); if(now > cutoffLow && now < cutoffHigh) { document.querySelector('#block-yui_3_17_2_1_1706642792709_17177').style.display = ""; } else{ document.querySelector('#block-yui_3_17_2_1_1706642792709_17177').style.display = "none"; } }); </script> Edited February 26 by lindz5223 Spelling Error Link to comment
tuanphan Posted February 29 Share Posted February 29 Can you share 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
Create an account or sign in to comment
You need to be a member in order to leave a comment