I have used a collapsible button which shows only on mobile and tablet screen. But when the "Show Less" button on mobile is tapped, the content on desktop also hides which I do not want. How do I fix that?
function myFunction() {
var x = document.getElementById("myDIV");
console.log(x.style.display);
if (x.style.display === "none" || !x.style.display) {
x.style.display = "block";
document.getElementById("moreButton").innerText = "Show Less";
} else {
x.style.display = "none";
var a = document.getElementById("servicenav");
document.getElementById("moreButton").innerText = "Show More";
a.click();
}
}
window.onresize = function(event) {
if(event.currentTarget.outerWidth >= 1026){
console.info("showing");
$("myDIV").show();
}else{
console.info("hiding");
$("#myDIV").hide();
}
}
<div id="myDIV">
<button class="get-started-btn morebutton" id="moreButton" onclick="myFunction()">Show More</button>
</div>