jeudi 5 août 2021

checkbox toggle and duplicate div value

I'm using the following script to toggle between 2 set values $0 and $53,498 in the middle div #t1.

<div class="row mb-3">
                            <div class="col-md-4 themed-grid-col"><label><input type="checkbox" autocomplete="off"  onclick="t1()"> Tuition</label></div>
                            <div class="col-md-4 themed-grid-col"><div id="t1">$0</div></div>
                            <div class="col-md-4 themed-grid-col"><div id="t1-total"></div></div> 
                          </div>
function myFunction() {
  const element = document.getElementById('demo')

  element.innerHTML = element.innerHTML === '$0' ? '$53,498' : '$0'
}

As I toggle between the 2 values $0 and $53,498 how do I apply the toggled value to the last div #t1-total. As per screenshotscreenshot I want the value in div 3 to equal the value in div 2 as I toggle the checkbox in div 1.

I only seem to be able to retrieve the $0 value and never $53,498.




Aucun commentaire:

Enregistrer un commentaire