0

I have to hide one web part on page or whole page (whatever I find quicker) on every Friday. I was sure javascript code will work, but it still shows web part.

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);

1 Answer 1

2

In your If statement - compare the values as below (double '=' instead of single '='):

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";          
}
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.