I wrote the code so that when entering two numbers he compared them and said which number is greater or they are equal, but the text with the result is not displayed.
What is the problem?
JS code:
function compNumb() var a,b,d; a = document.getElementById("i1").value; a = parseInt(a); b = document.getElementById("i2").value; b = parseInt(b); d = document.getElementById("out") if (a>b) { document.getElementById("out").innerHTML = "Первое число больше второго!"; } else if (a<b) { document.getElementById("out").innerHTML = "Второе число больше."; } else { document.getElementById("out").innerHTML = "Числа одинаковы."; } html code:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> <script src="1.js" defer></script> </head> <body> <p>Введите числа для сравнения! <input type="text" id="i1"></p> <p><input type="text" id="i2"></p> <p id="out">ТУТ</p> <hr> <button onclick="compNumb()">Сверяю</button> </body> </html>