Can't seem to add text to an H1 tag using .innerHTML

I've tried everything on this website, on every website, but for some odd reason, I can't seem to add text to an h1 tag. I've done this a million times before no issues but now it doesn't seem to work no matter what I do. The onClick functions work perfectly fine tho, so I know the function is being ran.

    const true1 = document.getElementsByClassName('True')
    const false1 = document.getElementsByClassName('False')
    const next = document.getElementsByClassName('next')
    const questione = document.getElementById('QuestionE')


function questionOne(){
      questione.innerHTML = "hello";

        true1[0].addEventListener('click', ((() => function aClickEvent(){
            true1[0].classList.toggle('TrueH')
             next[0].classList.toggle('nextS')
             }))(), false);

             false1[0].addEventListener('click', ((() => function aClickEvent(){
             false1[0].classList.toggle('FalseH')
             next[0].classList.toggle('nextS')
            }))(), false);

    }

   window.addEventListener('load', questionOne(), false);
window.addEventListener('load', questionOne(), false);

this is calling questionOne which returns nothing so you function is executing imediately before the DOM is there and you are attaching undefined as the function to call on load.

Try

window.addEventListener('load', questionOne, false);

Without the calling parenthesis.

Can, Can was the leading avant-garde rock group of the 70s. Can experimented with noise, synthesizers, non-traditional music, cut-and-paste techniques, and, most� Can definition, to be able to; have the ability, power, or skill to: She can solve the problem easily, I'm sure. See more.

Looks like you're trying to write immediately invoked function expressions, ie

(function blah(){})()

is this what you mean to do? You have click listeners, so maybe you meant something like this:

function questionOne() {
  questione.innerHTML = "hello";

  true1[0].addEventListener('click', () => {
    true1[0].classList.toggle('TrueH')
    next[0].classList.toggle('nextS')
  }, false);

  false1[0].addEventListener('click', () => {
    false1[0].classList.toggle('FalseH')
    next[0].classList.toggle('nextS')
  }, false);

}

btw 'hello' appears in my test...

The Official CAN / Spoon Records Website, Can may refer to: Contents. 1 Containers; 2 Music; 3 Other; 4 See also. Containers[edit]. Aluminum can � Drink can � Oil can � Steel and tin cans � Trash can� Define can. can synonyms, can pronunciation, can translation, English dictionary definition of can. to be able to, have the power or skill to: I can take a bus to the

This snippet works so I am assuming that you have incorrectly spelled QuestionE in the id as I cannot see your markup or the

const questione = document.getElementById('QuestionE')

runs before The element exists in the DOM. Try putting the line in the function or console.log(questione) and see if it has a value.

const questione = document.getElementById('QuestionE')

function questionOne(){
  questione.innerHTML = "hello";
}

window.addEventListener('load', questionOne, false);
<div id="QuestionE"></div>

Can, 1.4Used to indicate that something is typically the case. 'antique clocks can seem out of place in modern homes'. More example sentences. 110 synonyms of can from the Merriam-Webster Thesaurus, plus 97 related words, definitions, and antonyms. Find another word for can. Can: to bring (as an action or operation) to an immediate end.

Can (band), can noun [C] (CONTAINER) � can verb [T] (CONTAIN) � can modal verb (ABLE) � can modal verb (PERMIT) � can modal verb (BE POSSIBLE) � can� Can (stylised as CAN) was a German experimental rock band formed in Cologne in 1968 by the core quartet of Holger Czukay (bass, tape editing), Irmin Schmidt (keyboards), Michael Karoli (guitar), and Jaki Liebezeit (drums).

Can, VerbEdit. can (third-person singular simple present can, present participle -, simple past could, past participle (obsolete except in adjectival use) couth). HANGZHOU, China, Aug. 04, 2020 (GLOBE NEWSWIRE) -- Canaan Inc. (NASDAQ: CAN) ("Canaan" or the "Company"), a leading high-performance computing solutions provider, today announced that the terms of

CAN, Word forms � 1. countable noun A can is a metal container in which something such as food, drink, or paint is put. � 2. verb [usually passive] When food or drink is� A Controller Area Network (CAN bus) is a robust vehicle bus standard designed to allow microcontrollers and devices to communicate with each other's applications without a host computer. It is a message-based protocol , designed originally for multiplex electrical wiring within automobiles to save on copper, but can also be used in many other

Comments
  • What is with the self executing functions that return a function?
  • @AdrianBrand What do you mean? Talking about the window.addEventListener?
  • (() => function() {})() this is a self executing function that returns a function, you could just write function() {}
  • When you've added a minimal reproducible example that reproduce the issue described, and it should be within the question, someone will be able to assist.
  • Yeah nothing, onClick functions still works that way but, still doesn't add the "hello" to the h1 tag
  • Yeah that makes the onClick functions a little simpler and less cluttered, but it still doesn't help with the .innerHTML. The onClick functions work just fine
  • and exactly, it makes no sense it's not showing up in mine, there are no errors, everything is spelt correctly, its driving me crazy lol
  • Just had a thought - you are loading your script after the html has loaded, or doing something like: document.addEventListener("DOMContentLoaded", function(){ // Handler when the DOM is fully loaded });
  • <h1 id="QuestionE"></h1> Yeah no its spelt correctly, just magically doesn't work lol
  • Where is the script, what I quess is happening is that the document.getElementById('QuestionE') is being run before the DOm has the h1 in it. Try moving the document.getElementById('QuestionE') into the function as that is run after load.
  • Just tried it and nothing :/. I'm so confused right now