I've used a lot of getElementById.innerHTML
to populate a table on click of certain buttons. I want to have a function where it will use an if command, so that, when clicked, if the text in box id 'B2' is 'x' then it will return 'y' in id 'pc2', if not (else) , it will return 'z' in element with ID 'pc2'. I can't get it to work.
Here's what I tried, please help.
if (document.getElementById("B2").innerHTML = 'x' {
document.getElementById("pc2").innerHTML = 'y'
} else {
document.getElementById('pc2').innerHTML = 'z'}
}
I have tried it by putting each step into variables and no difference. It changes what is in B2 and treats it as true
regardless. Thanks very much, I'm very early to all this and don't know jQuery, just rudimental java.
Aucun commentaire:
Enregistrer un commentaire