onsubmit后触发Jquery事件

发布于 2024-10-09 12:12:44 字数 63 浏览 0 评论 0原文

我想在表单完成操作后触发 Div 打开。但我只需要它基于一个特定的操作发生,所以它是特定的。我不知道从哪里开始。

I would like to trigger a Div to open after a form completes an action. But I need to it only happen based on one particular action so it is specific. I'm not sure where to start.

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

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

发布评论

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

评论(1

最舍不得你 2024-10-16 12:12:44

好的,如果您的表单完成操作(即您已提交)后未加载新页面,我会假设您的意思是您没有将用户重定向到其他页面;您只是用更新的数据发回当前的“购物车”页面。

所以你的问题是,“如何仅在回发后在我的页面上显示内容”。

虽然 jQuery 可以完成所有事情,但这里可能不需要(如果至少我已经正确解释了你的问题)。

您只需要检查页面是第一次加载还是为了响应回发而加载。为此,您可以使用 Page.IsPostBack 属性:

<% if (Page.IsPostBack) { %>
   <div id="myMessage"><p>You added something to your cart.</p></div>
<% } %>

如果这不是您的意思,您需要进一步解释您的问题。

Ok, so if a new page is not loaded after your form completes an action (i.e. you have submitted it), I would assume you mean you're not redirecting the user to a different page; you're just posting back the current "Cart" page with the updated data.

So your question is, "How do I display content on my page only following a postback".

While jQuery does all things, it's probably not needed here (if I've interpreted your problem correctly, at least).

You just need to check whether the page is being loaded for the first time or is being loaded in response to a postback. For that you use the Page.IsPostBack property:

<% if (Page.IsPostBack) { %>
   <div id="myMessage"><p>You added something to your cart.</p></div>
<% } %>

If this isn't what you meant, you need to explain your question a bit more.

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