gpt4 book ai didi

javascript - jquery点击问题

转载 作者:行者123 更新时间:2023-11-30 06:56:32 25 4
gpt4 key购买 nike

我有一个问题。

代码是这样的:

$("#button").click(function(event){
$("#threads").html("hi");
});

当我点击按钮时,文本“hi”仅在 1 秒内显示。然后它消失了。我希望它在我点击后始终显示。我该怎么做?

最佳答案

试试这个:

$("#button").click(function(event){
event.preventDefault();
$("#threads").html("hi");
});

我的猜测是按钮是一个 [a href] 标签或导致页面刷新的表单。

关于javascript - jquery点击问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1856691/

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