# How to use plugins.ngclientutils.addClassToDOMElement

**URL:** <https://forum.servoy.com/t/how-to-use-plugins-ngclientutils-addclasstodomelement/20454>\
**Category:** Questions\
**Created:** [March 18, 2021, 8:08am UTC](https://forum.servoy.com/t/how-to-use-plugins-ngclientutils-addclasstodomelement/20454 "2021-03-18T08:08:36Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Juan\_Etec](https://avatars.discourse-cdn.com/v4/letter/j/b4bc9f/32.png) [@Juan\_Etec](https://forum.servoy.com/u/Juan_Etec)\
**Post date:** [March 18, 2021, 8:08am UTC](https://forum.servoy.com/t/how-to-use-plugins-ngclientutils-addclasstodomelement/20454/1 "2021-03-18T08:08:36Z")

</div>

Hi,  
I try to use plugins.ngclientutils.addClassToDOMElement(jQuerySelector,className) but I don’t know how.

I try:

- plugins.ngclientutils.addClassToDOMElement(“:contains(‘unique\_name’)”,‘hidden-md hidden-lg’);
- plugins.ngclientutils.addClassToDOMElement(“[svy-name=‘unique\_name’]”,‘hidden-md hidden-lg’);

Un Saludo

---

<div class="post-metadata">

**Author:** ![mboegem](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/mboegem/32/4399_2.png) [@mboegem](https://forum.servoy.com/u/mboegem)\
**Post date:** [March 18, 2021, 10:42pm UTC](https://forum.servoy.com/t/how-to-use-plugins-ngclientutils-addclasstodomelement/20454/2 "2021-03-18T22:42:56Z")

</div>

Not sure, but shouldn’t you also specify the element itself to have a fully qualified selector?  
Like this:

```auto
plugins.ngclientutils.addClassToDOMElement("div:contains('unique_name')",'hidden-md hidden-lg');
plugins.ngclientutils.addClassToDOMElement("div[svy-name='unique_name']",'hidden-md hidden-lg');

```

---

<div class="post-metadata">

**Author:** ![Juan\_Etec](https://avatars.discourse-cdn.com/v4/letter/j/b4bc9f/32.png) [@Juan\_Etec](https://forum.servoy.com/u/Juan_Etec)\
**Post date:** [March 20, 2021, 8:58am UTC](https://forum.servoy.com/t/how-to-use-plugins-ngclientutils-addclasstodomelement/20454/3 "2021-03-20T08:58:32Z")

</div>

Hi Marc, thanks for your reply.

It works in those cases:

```auto
plugins.ngclientutils.addClassToDOMElement('div[svy-name="unique_name"]','hola');
plugins.ngclientutils.addClassToDOMElement('[svy-name="unique_name"]','hola2');

```

I put it in the onShow process and it does not work, but if I put it in another process like onfocusgain or onrecordselection it works.  
Is there any trick to make it works after the onShow?

Thanks

---

<div class="post-metadata">

**Author:** ![mboegem](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/mboegem/32/4399_2.png) [@mboegem](https://forum.servoy.com/u/mboegem)\
**Post date:** [March 22, 2021, 8:24pm UTC](https://forum.servoy.com/t/how-to-use-plugins-ngclientutils-addclasstodomelement/20454/4 "2021-03-22T20:24:41Z")

</div>

Hi Juan,

the addClassToDOMElement function is really meant to be used to add non-peristent classes to a DOM element to achieve really dynamic behaviour.  
At the time of execution of the onShow, the page is not fully loaded yet so any change to the page generated by Servoy will be neglected or not even possible, because the DOM element does not yet exist.

Can you please describe/post images on what you are trying to do here?  
I don’t think you are on the correct path to achieve what you want.

---

<div class="post-metadata">

**Author:** ![paronne](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/paronne/32/5096_2.png) [@paronne](https://forum.servoy.com/u/paronne)\
**Post date:** [March 25, 2021, 7:24am UTC](https://forum.servoy.com/t/how-to-use-plugins-ngclientutils-addclasstodomelement/20454/5 "2021-03-25T07:24:23Z")

</div>

Hi Juan,

i assume your form is a Responsive Form.  
With the latests versions of Servoy is possible to add/remove styleClass to Layout Containers such as div etc…  
You can give a name to the container e.g. ‘myContainer’.  
You can then add/remove styleClass to the container with

```auto
containers.myContainer.addStyleClasses(classes)

```

Regards,  
Paolo
