hello,
i tried to build a very simple function, and i failed allready. dissapointing. I can not find where i went wrong. plz help me.
button 1: it should change the wordt "haai" to "yoyo" and then to "hallo". it does change haai to yoyo, but not beyond.
button 2: it should change color (it does, so works fine).
regards, ronald
<script>
function hello() {
var x = document.getElementById("hey");
if(x = "haai"){
var y = "yoyo";
}else{
var y = "hallo";
}
document.getElementById("hey").innerHTML = y;
}
function red(){
document.getElementById("hey").style.color = "red";
}
</script>
<button onClick="hello()">click me</button>
<button onClick="red()">click me</button>
<p id="hey">haai</p>