How to change HTML in the following code using JavaScript?

  Kiến thức lập trình

Basically, I want to change the text of whatever this is, but i don’t know how. I tried everything from changing to textContent of the first div child to trying to change the value of the second child. What should I do?

<div class="css-1dorzr0" id="input-963-dateSectionYear" tabindex="-1"><div aria-hidden="true" id="input-963-dateSectionYear-display" data-automation-id="dateSectionYear-display" class="css-1ir684o">YYYY</div><input role="spinbutton" aria-describedby="helpText-input-963 error1-input-963" aria-label="Year" aria-valuemax="9999" aria-valuemin="1" aria-valuetext="YYYY" id="input-963-dateSectionYear-input" data-automation-id="dateSectionYear-input" class="css-72im0m" value=""></div>

    endYear = ["2026"]
    let startYearInput = document.querySelectorAll(`div[data-automation-id="dateSectionYear-display"]`)[0]
    let startYearInput2 = document.querySelectorAll(`input[data-automation-id="dateSectionYear-input"]`)[0]
    if (startYearInput && startYearInput2) {
      await new Promise(resolve => setTimeout(resolve, 1000));
      startYearInput.innerHTML = startYear[0]
      startYearInput2.value = startYear[0]
      dispatchChangeEvent(startYearInput)
    }
    else {
      alert("Bye")
    }  ```

LEAVE A COMMENT