this is my html list-
<ul id="board">
<li class="card" id="card1a">1</div>
<li class="card" id="card1b" >2</div>
<li class="card" id="card2a" >3</div>
<li class="card" id="card2b" >4</div>
</ul>
I made to an array in javaScript:
var cards=document.getElementsByClassName("card");
Than I tried to replace elements inside the array-
var temporaryValue = cards[0];
cards[0] = cards[2];
cards[2] = temporaryValue;
It didn't work: cards[0] and card[2] stayed in the same values. I don't know why. Please help!
ulandli) our just inside thecardsvariable?<li>elements they're pointing to. If you want to "change" the HTML, you need to remove a<li>, then insert it elsewhere.