How to change the style of an element with Javascript?

0
I have a nanoflow with a Javascript call. I would like to change the css attributes of a DOM element. I have checked in the console : my element exists and is not empty.   The problem is that the javascript instructions I knew are not recognized by Mendix. How to something like myElement.style.attribute = ‘value’?   Thanks
asked
2 answers
4

Hi Ariel,

 

Normally I would say to create a class and do you styling on that. However sometimes this is (sadly) not possible. You can use JS for that with the following syntax:

var ObjectInDom = document.getElementsByClassName('ClassName')[0]; // Make sure you can identify only 1 object
ObjectInDom.style.setProperty('height', '100%');

In the setProperty you can put whatever style you want. See https://www.w3schools.com/jsref/met_cssstyle_setproperty.asp

 

Good luck

answered
0

well some ways are 

1.write a nanoflow on the page add the javascript call to it

in that java script call u can write any java script code which will work.

 

2.add the HTMl snippet and add the javascript there.

 

answered