pretty new to coding. But I have a small assignment where I just not get what function I should do or how I should write it down. Basicly it should give an input box and a button (this works). But now I want to give an alert IF the input is hi and a different alert if the input is bye. For all other inputs there shouldn't happen anything. I'm just not getting it, can someone help out?
<h1>Welcome</h1>
Input: <input id="welcome1" type="text" />
<button id="button">Click here</button>
</body>
<script type="text/javascript">
if (document.getElementById("welcome1").textContent = "hi"){
document.getElementById("button").onclick = alert("Welcome");
}
else (document.getElementById("welcome1").textContent = "bye"){
document.getElementById("button").onclick = alert("See you later");
}
</script>
Aucun commentaire:
Enregistrer un commentaire