Skip to main content
New Idea

`hidden` HTML attribute is removed when solution article is published

Related products:Freshdesk
  • April 10, 2024
  • 0 replies
  • 18 views

Kaley White
Contributor
Forum|alt.badge.img+7

I added the hidden attribute to an element in the solution article Code View:

<p hidden class="hide">Text to hide</p>

When I publish the article, that attribute is removed.

<p class="hide">Text to hide</p>

I added the following code in the Article view page on my theme so that on page load, the hidden attribute is added appropriately, but I’d like for it not to be removed in the first place. The same issue occurs with aria-hidden.

document.addEventListener('DOMContentLoaded', async function() {
let div = document.querySelector('div[class="fw-content fw-content--single-article line-numbers"]');

let hideElems = div.querySelectorAll('.hide');
hideElems.forEach(function(elem) {
elem.hidden = true;
});
});