我尝试创建注销按钮,但我不知道该使用什么。
如何让注销文本在几秒钟内更改为“等待..”,然后切换为“成功”?
我还需要学习jquery。
function logout() {
$("#logout").text("Waiting...", 3000);
$("#logout").text("Success!", 1000);
closeWindow();
}
document.addEventListener('DOMContentLoaded', function() {
document.getElementById('logout').addEventListener('click', logout);
});
HTML:
<button type="button" class="list-group-item" id="logout"> Log out</button>
你能帮我提供引用吗?
我从这个引用文献中了解到:W3Schools.com
最佳答案
这可能有助于尝试一下:
function logout(){
$("button").text("waiting...");
setInterval(sucess,3000)
}
function sucess(){
$("button").css("background","green");
$("button").text("successfull");
clearInterval();
}
$("button").click(logout);
button{
background:orange;
border:none;
color:white;
padding:20px 20px;
font-size:20px;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<script src="https://code.jquery.com/jquery-3.1.0.js"></script>
</head>
<body>
<button>Log out</button>
</body>
</html>
关于javascript - jQuery text() 方法加载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48335124/