.style.display not working

I am using a document.getElementById for a let with the target being the id of an entire span. Then I use .style.display to set its display. Similar to this

<button onclick="show()"
<span id="jsadd">
<p > Lorem ipsum sit dolor amet </p>
<!-- and so on -->
#jsadd {
display: none;
function show() {
let add = document.getElementById("jsadd");
add.style.display (add.style.display ===  "none")  ? add.style.display = "block"  : add.style.display = "none"

Is it intended to look like this in the scripts.js file?

let base = document.document.getElementById("jsbase");

what’s the difference?

Well, the reason it’s not working seems to be that document is there duplicated. There’s no document.document, so document.document.getElementById("jsbase"); won’t work.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.