运行函数/效果一次然后停止

发布于 2024-07-10 10:50:18 字数 190 浏览 6 评论 0原文

我正在尝试找到一种方法,使用没有 cookies 的 jquery 来显示一个块,然后单击它来 hide() 并且不再显示。

它是我页面上临时正在建设的div

有什么方法可以单击它来关闭它,这使用 jQuery 很容易,然后不再加载它? 因为它不会出现在其他页面上吗?

I am trying to find a way using jquery without cookies to display a block and click it to hide() and not show again.

It is a temporary under construction div on my page.

Is there any way to click it to close, which is easy enough using jQuery, then not have it load again? For it won't on the other pages?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

江湖彼岸 2024-07-17 10:50:18

通过布尔变量的条件检查加载 div。 因此,在伪代码中:

var HasBeenViewed = false;

If (!HasBeenViewed)
{
  show div;
  HasBeenViewed = true; 
}

编辑: 为了使其无法在其他页面上工作,您需要在客户端或服务器上的某处使用 cookie 或某种状态持久性。

Load the div with a conditional check of a bool variable. So in pseudocode:

var HasBeenViewed = false;

If (!HasBeenViewed)
{
  show div;
  HasBeenViewed = true; 
}

Edit: for it not to work on other pages you would need to use a cookie or some sort of state persistence somewhere, either on the client or the server.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文