刷新页面后,标签内容消失。 我应该改变什么,以免这种情况发生?
var versuche = 3; //login attempts
function validate(){
var username = document.getElementById("username").value;
var password = document.getElementById("password").value;
if ( username == "DjolePhillip" && password == "passwort12345")
{
alert ("Login erfolgreich");
window.location = "loggedin.html";
document.getElementById("loginname").innerHTML = username; //label gets the username
return false;
}
else{
versuche --;
alert("Du hast "+versuche+" uebrig;");
if( versuche == 0)// if no attempts left
{
document.getElementById("username").disabled = true;
document.getElementById("password").disabled = true;
document.getElementById("submit").disabled = true;
return false;
}
}
}

<div id="anmeldung">
<center id="anmeldename"><label id="loginname"></label></center>
</div>
&#13;
以上是完整的代码。
答案 0 :(得分:0)
您必须在某处保留数据。服务器端有ajax请求,客户端有SessionStorage或LocalStorage。
<div class="row" id="options">
<div class="col-md-2"><div class="checkbox">
<label><input type="checkbox" name="nor" id="norA">A</label>
</div>
<div class="checkbox">
<label><input type="checkbox" name="nor" id="norB">B</label>
</div></div>
<div class="row" id="result">
<div class="col-md-2"><p id="nors">on</p></div></div> <!--placeholder of the solution/output -->