【发布时间】:2021-12-25 05:05:04
【问题描述】:
由于某些原因,我无法使用 javascript 显示#coupon,当我尝试获取 elementById 时,它会显示错误消息 elementById undefined,
HTML
<html>
<head>
<title>Exercise</title>
<link rel="stylesheet" href="stylesheet.css">
<script src="javascript.js"></script>
</head>
<body>
<div class="inputi">
<p class="input-text">Une Jam?</p> <input placeholder="Sheno emrin..." type="text" id="inputId">
//checks input value
<button type="button" onclick="getInputValue()">Vazhdo</button>
// shows error message if it doesn't match the array
<p id="message"></p>
</div>
// i want to display this with javascript, after the login
<h1 id="coupon">You won giftcard </strong></h1>
<button id="coupon">abas</button>
</body>
</html>
JS(问题)
** 问题 getElementById 未定义,我想在成功登录尝试后显示:阻止。 **
var zzz = getElementById("coupon")
if(zzz === "none") {
display:block; }
// document.writeln("<h1>Keni fituar kupon 50% ne <strong> Green & Protein </strong> </h1>");
// document.writeln('<input class="giftcode" placeholder="' +finalcode+'" type="text" id="inputId">');
display_image(images[z], 400, 400, 'Javascript');
document.write('<br>' + user[i]);
}
}
}
【问题讨论】:
-
不是您遇到的主要问题,但
id在文档中应该是唯一的。您有两个具有相同couponid 的元素。
标签: javascript html css dom