How can I hide a div?

I was trying to use Custom Script section on the page and write something like this there:

document.getElementsByClassName(‘navigation’).style.display = ‘none’;

But it doesn’t seem to work. Can you help me figure this out?

@famousright, Google can help too…

When searching for getElementsByClassName, Google will return the following page as first entry in its results: Document.getElementsByClassName() - Web APIs | MDN

According the docs:

The getElementsByClassName method of Document interface returns an array-like object of all child elements which have all of the given class name(s).

In the Examples section:

Get the first element with a class of ‘test’, or undefined if there is no matching element:

document.getElementsByClassName('test')[0]

But this is still not working. Can I just write scripts in this section?

@famousright,

Custom Script section

  • What is this so called “Custom Script section”?
  • Which theme are you using?


This section. We are using our company custom theme.

@famousright

We are using our company custom theme.

Then you should ask the developers of the theme… The community has no insight in the custom theme used by your company.

Isn’t this universal for all themes? Can theme block custom scripts?

@famousright, No there is no universal “Custom Script section” in Grav themes.

By the way, why would you want to hide an element with class “navigation”?

Anyway, I would suggest you talk to the developers of the custom theme used by your company.

I can’t reach them anymore because they are not working at the company.

There is a Custom Script section on the page where I want execute this script. I just don’t know why it may be not working.

I want to hide navigation because this is what requested by our company for this page

@famousright,

I can’t reach them anymore because they are not working at the company.

If the agency or internal developers can no longer be reached, your company might consider:

  • Hiring someone or an agency:
    • To dig into the code and answer your question.
    • To maintain the code.
  • Publish the theme to allow someone in the community to have a look
  • Drop the requirement to hide the ‘navigation’ element.

Again, without the community knowing what the “Custom Script section” does and not being able to dig into the code of the theme, there is not much we can do here…

2 Likes