mardi 3 février 2015

Basic Javascript If not working

I have made a basic javascript if statement but it does not seem to working.

Here's my code:


HTML:



<span id = 'link'>
<a onclick = 'show()' href = 'javascript:void(0);'>Show</a>
</span>
<span id = 'box'>
asdf
</span>


Javascript:



function show(){
var span1 = document.getElementById("box").innerHTML;

if(span1 == 'asdf'){
document.getElementById("box").innerHTML = 'test';
}
}


Any suggestions?


Aucun commentaire:

Enregistrer un commentaire