I have made a basic javascript if statement but it does not seem to work. It doesn't replace the text in the Span 'box', but does without the if statement.
Here's my code:
function show() {
var span1 = document.getElementById("box").innerHTML;
if (span1 == 'asdf') {
document.getElementById("box").innerHTML = 'test';
}
}
<span id = 'link'>
<a onclick = 'show()' href = 'javascript:void(0);'>Show</a>
</span>
<span id = 'box'>
asdf
</span>
Any suggestions?
console.log(span1)and make sure there are no spaces around