Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Themes & Styling

How can I hide a div?

Started by Stas Yaremenko 5 years ago · 9 replies · 488 views
5 years ago

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?

5 years ago

@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:

JS
document.getElementsByClassName('test')[0]
5 years ago

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

5 years ago

@famousright,

Custom Script section

  • What is this so called "Custom Script section"?
  • Which theme are you using?
5 years ago

@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.

5 years ago

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

5 years ago

@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.

5 years ago

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

5 years ago

@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

Suggested topics

Topic Participants Replies Views Activity
Themes & Styling · by Pedro M, 2 months ago
4 222 2 months ago
Themes & Styling · by Ian, 2 months ago
3 118 2 months ago
Themes & Styling · by Norbert, 2 years ago
11 481 3 months ago
Themes & Styling · by Lukáš Findeis, 3 months ago
0 72 3 months ago
Themes & Styling · by Sebadamus, 4 months ago
5 132 3 months ago