How can I hide a div by ID / Class using a parameter in the URL?
For example site.com/?divID=hide
Or disable a specific CSS to act another. But it had to be through the URL: /
How can I hide a div by ID / Class using a parameter in the URL?
For example site.com/?divID=hide
Or disable a specific CSS to act another. But it had to be through the URL: /
2
Answers
You will get URL params in "urlParams" object and use that "urlParams[divID]" to get the details of URL params and apply CSS using jQuery/js .
Here is the syntax of jQuery to apply CSS
https://www.w3schools.com/jquery/jquery_css.asp
Here is the syntax of js to apply CSS
https://www.w3schools.com/js/js_htmldom_css.asp
In HTML, you can hide any element you want by giving it the
hidden
parameter.This will hide the div and it’s content.
If you wanted to do it using PHP, you could do the following: (assuming your URL is
site.com?hide
)What
<?= $hide ? "hidden":""?>
does is basically, if the GET parameterhide
is set, will print in your HTML (inside your div tag) the word ‘hidden’, which will make your div invisible.