Only Show Component if it’s the First Week of the Month
This is a solution to hide your component unless it is the first day of the month.
- Not yet re-checked
- Classic builder
Moved from our previous help site and not yet re-checked against the current product. Last edited Sep 20, 2024.
This is a solution to hide your component unless it is the first day of the month.
One Easy Step
Add the following code to the JavaScript tab of the page.
Date.prototype.getWeekOfMonth = function() {
var firstWeekday = new Date(this.getFullYear(), this.getMonth(), 1).getDay();
var offsetDate = this.getDate() + firstWeekday - 1;
return Math.floor(offsetDate / 7);
};
TB.render('component_ID', function(data) {
if(new Date().getWeekOfMonth() !== 0){
data.ele.css('display','none');
}
});
Original Community Post:
Was this page helpful?
Something wrong or missing on this page? Tell us.