Set HTML from JS Script?

I'm just messing with a toggle button to change the HTML of the toggle. Is it possible to do this, and if so then I imagine my code below could be wrong? Does anyone have any thoughts?

<div id="myDIV" style="display: block;">
This is my DIV element.
</div>
var x = document.querySelectorAll('id > div > div');
value === 1 ? x.style.display = "none" :  x.style.display = "block";

I get a console error which makes me believe this may not be possible.

html_1/script.script javascript error at line 2: TypeError: Cannot set property 'display' of undefined

Using the inspector I can target the div though
image

Edit:

I could also target the HTML using after reading the documentation and seeing that the HTML div is automatically applied to each widget.

document.querySelector("#WIFiJSb93n > .html").innerText

Cheers,
DMDComposer

Widget scripts can't access the DOM, the list of available functions can be found in the documentation.

1 Like