How do I disable one function if another is enabled in Javascript?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


How do I disable one function if another is enabled in Javascript?



PREFACE: I know close to NOTHING about javascript.



I've got the following javascript code on a webpage I'm working on:


function Printed() {
var x = document.getElementById("PRIMP");
if (x.style.display === "none") {
x.style.display = "block";
} else {
x.style.display = "none";
}
}

function Digital() {
var x = document.getElementById("DIGMP");
if (x.style.display === "none") {
x.style.display = "block";
} else {
x.style.display = "none";
}
}



Essentially, I've got a page that displays certain content when the Printed function is active and other content when Digital is active (this is working currently).



The issue is that if someone were to, say, click to see the Digital content AFTER they've clicked to see the Printed content, I need the Printed content to disappear so that only one segment of content is visible at any one time (and vice-versa).



Thus, I need to know what to add/change to this existing code to make that happen.





You should use CSS and media queries instead.
– SLaks
3 mins ago





Just look at what the code does to display something (if hidden, then show, else hide). Write the opposite of that in each opposing function.
– csmckelvey
44 secs ago











By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Keycloak server returning user_not_found error when user is already imported with LDAP

PHP parse/syntax errors; and how to solve them?

How to scale/resize CVPixelBufferRef in objective C, iOS