gpt4 book ai didi

Javascript - 动态创建按钮

转载 作者:行者123 更新时间:2023-11-30 16:52:26 25 4
gpt4 key购买 nike

我想使用 JavaScript 和 jQuery 动态创建一个按钮。

下面的代码是测验的最后一部分,当测验完成时,它会给出结果并说明您已完成。我想在此期间使用 JS 动态创建一个按钮,将用户带回主页 (index.html)。

非常感谢任何帮助。

function displayFinalSlide(){

$(stage).append('<div class="questionText">You have finished the quiz!<br><br>Total questions: '+numberOfQuestions+'<br>Correct answers: '+score+'</div>');

}//display final slide

最佳答案

试试这个:就像添加 html 一样,只需添加 anchor 标记/按钮即可

function displayFinalSlide(){

$(stage).append('<div class="questionText">You have finished the quiz!<br><br>Total questions: '+numberOfQuestions+'<br>Correct answers: '+score+'</div><a href="index.html">Index Page</a>'); // here in href you can give the path where you want to redirect to

}

关于Javascript - 动态创建按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30316642/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com