jQuery text()加载方法(jQuery text() Method with loading)
我尝试创建注销按钮,但我不知道要使用什么。
如何在几秒钟内将注销文本更改为“正在等待......”,然后切换到“成功”?
我仍然需要学习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
I try to create Logout button, but I have no idea what to use.
How to keep the logout text changed to "Waiting.." in a few seconds, after which it switches to "Success"?
I still need to learn 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>Can you help me with references?
I learned from this reference : W3Schools.com
最满意答案
document.addEventListener('DOMContentLoaded' ....不需要,3秒后click按钮更新Success消息。使用setTimeout来引入延迟
function logout() { $("#logout").text("Waiting...", 3000); setTimeout(function() { $("#logout").text("Success!", 1000); }, 3000) } document.getElementById('logout').addEventListener('click', logout);<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <button type="button" class="list-group-item" id="logout"> Log out</button>document.addEventListener('DOMContentLoaded' .... is not needed & on click of the button update with Success message after 3 secs. Use setTimeout to introduce the delay
function logout() { $("#logout").text("Waiting...", 3000); setTimeout(function() { $("#logout").text("Success!", 1000); }, 3000) } document.getElementById('logout').addEventListener('click', logout);<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <button type="button" class="list-group-item" id="logout"> Log out</button>
更多推荐
发布评论