I have a calendar displayed on a page that shows the "calendar" view by default, which, does not display well on mobile. The calendar has a button to change to a "list" view.
I am trying to use javascript to click that button if the screen size is less than 767px. The code below is not working. Any help?
Thanks!
<script>
function viewForm(){
if (window.innerWidth > 767) {
function buttonclick(){
var pagebutton= document.getElementsByClassName("fc-listMonth-button");
pagebutton.click();
}
}
};
window.addEventListener('resize', viewForm);
</script>
you just need to remove buttonclick function, because you didn't call it.
<script>
function viewForm(){
if (window.innerWidth > 767) {
var pagebutton= document.getElementsByClassName("fc-listMonth-button");
pagebutton.click();
}
};
window.addEventListener('resize', viewForm);
</script>