How to hide an HTML element on load of a record producer?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-15-2023 09:04 AM
Hello,
I have a record producer and I want to hide the part that is marked with red, as shown below.
If I inspect the HTML, this looks like this:
How can I hide this part on load of the record producer??
An onload script will work, but how the code should look like for the aforementioned purpose?
Thank you,
Smith.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-15-2023 02:06 PM
Hi, for a client script you would use setDisplay(),
GlideForm | ServiceNow Developers
OOB examples
/catalog_script_client_list.do?sysparm_query=scriptLIKEsetDisplay&sysparm_view=
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-16-2023 12:05 AM - edited ‎06-16-2023 12:05 AM
Hi,
unfortunately, what I want to hide is not a variable.
This is out of the box HTML element on a record producer on Shopping Hub.
That's why I need somehow to hide it with DOM manipulation.
Any ideas?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-16-2023 01:28 AM
Hi @Smith Johnson ,
Hope you are doing good.
Here's an example code snippet that demonstrates how to hide an HTML element using DOM manipulation:
var elementToHide = document.getElementById('elementID');
// Check if the element exists before attempting to hide it
if (elementToHide) {
elementToHide.style.display = 'none';
}
And if this element is there only in widget and you cannot access in on load script then , You need to copy this OOB widget and change CSS of sn-panel header.
set the css as below :
.sn-panel-header{
display : none;
}
and then add this new widget in respective page designer. To open page designer you can directly right click on portal page by pressing control key.
Regards,
Riya Verma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-16-2023 05:59 AM
Hello @Riya Verma ,
thanks for your response.
I think that this will not work in my case.
document.getElementById('elementID');
After inspecting the HTML, I don't see an id for my div element.
I only see a class.
How the code should look like to get this element based on its class name?