简体   繁体   English

模拟单击链接以显示通知-jQuery和CSS3

[英]Simulate Clicking on link to show notification - jQuery and CSS3

I can currently only show a notification bar by physically clicking on the link. 我目前只能通过物理地单击链接来显示通知栏。 I want this to be automated by jQuery simulating a click to show the notification bar. 我希望通过jQuery模拟单击以显示通知栏来使其自动化。

The notification code is: 通知代码为:

<div class="success message" id="success_message">
    <h3>Success!</h3>
    <p>Reserved Listing has been added to the system!</p>
</div>

Which only shows if I click on: 仅当我单击时显示:

<a href="#" class="trigger success-trigger">Test</a>

Any help on a jQuery script to simulate clicking the above code would be highly appreciated. 我们非常感谢您提供有关jQuery脚本以模拟点击上述代码的任何帮助。 I am aware I would need an id tag to reference it? 我知道我需要一个id标记来引用它吗?

Many thanks in advance 提前谢谢了

$("a.success-trigger").click();

If this is the only anchor that triggers your success bar then you should use an ID. 如果这是触发成功栏的唯一锚点,则应使用一个ID。 Either way something like: 两种方式都可以:

<a id="successTrigger"></a>

`$("#successTrigger").trigger("click");

should work 应该管用

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM