What's new

Welcome to the forum 👋, Visitor

To access the forum content and all our services, you must register or log in to the forum. Becoming a member of the forum is completely free.

Cant show/hide within <details>

knowncoder

New member
Joined
May 2, 2024
Messages
2
Reaction score
0
HTML Coins
0
Hello, It seems that I cannot show/hide within the HTML <details> tag . I am using the following javascript

`
document.addEventListener('change', function() {
var usaDiv = document.querySelector('.usa');
var canDiv = document.querySelector('.can');

var regionDropdownValue = getCookie('RegionDropdown');

if (regionDropdownValue === 'USA') {
usaDiv.style.display = 'block';
canDiv.style.display = 'hidden';
} else if (regionDropdownValue === 'CAN') {
usaDiv.style.display = 'hidden';
canDiv.style.display = 'block';
} });`

to try and do so and it doesn't work as soon as I nest the <div class="usa"> tag within the <details> tag. Does anybody have a solution or know a work around where I can still use javascript?
 
You mean hide or show a content within the html document?
Add this to the html div <div id="myDiv"> Toggled div </div>
This goes in your javascript

function evaluateBoolean() {

const div = document.querySelector("#myDiv");

if (location.hostname.indexOf("someval" > 0) { //you would add the value of the hostname.indexOf here. " "

div.hidden = true;

} else {

div.hidden = false;
}
//that is called the conditional statement. What is being done on a browser. True or false.

That's how you hide the content.
 
Last edited:
if you wrap something in <summary> and then <details> the details dropdown will not let javascript control what is shown or hidden in it because the details by default is hide or show so it overrides the javascript. So I was trying to find a way to override this
 

Theme customization system

You can customize some areas of the forum theme from this menu.

  • Wide/Narrow view

    You can control a structure that you can use to use your theme wide or narrow.

    Grid view forum list

    You can control the layout of the forum list in a grid or ordinary listing style structure.

    Picture grid mode

    You can control the structure where you can open/close images in the grid forum list.

    Close sidebar

    You can get rid of the crowded view in the forum by closing the sidebar.

    Fixed sidebar

    You can make it more useful and easier to access by pinning the sidebar.

    Close radius

    You can use the radius at the corners of the blocks according to your taste by closing/opening it.

  • Choose the color combination that reflects your taste
    Background images
    Color gradient backgrounds
Back