Search code examples
javascriptsharepoint-2013web-parts

Hide web part on Sharepoint 2013 page on certain day


I have to hide one web part on page or whole page (whatever I find quicker) on every Friday. I made javascript code few months ago to hide web parts after 10AM, so I edited that code for new purpose.

window.addEventListener("load", function(){
 var currentDay = new Date();
 var day = currentDay.getDay();
 var hideMe = document.getElementById("MSOZoneCell_WebPartWPQ3");  
 /* This is web part that I need to hide */

if(day=3) { /* I put 3 for today to check if it will work, but I need Friday as a day */
 hideMe.style.display = "none";          
}
else {
 hideMe.style.display = "block";
}
}, false);

Solution

  • I put == instead of = inside If clause

    if(day==3)  
    

    and now it works.