Reputation: 91
I used a Wordpress theme where a popup is build in. The popup shows when click on this link:
<a href="#etheme-popup" class="etheme-popup">Nieuwsbrief</a>
So it activated with this id etheme-popup
Now i want trying the popup shows automatic after a delay of 2 seconds. So adding this code snippet, but doesn't work:
<script>
jQuery(document).ready(function($) {
setTimeout(function() {
$('#etheme-popup').show(); }, 2000);
});
</script>
Hope somebody can help me.
PS: Adding the code in theme's functions.php:
function popup_delay() {
$newsletter_popup = '
<script>
jQuery(document).ready(function($) {
setTimeout(function() {
$(\'#etheme-popup\').show(); }, 2000);
});
</script>';
echo "\n" . $newsletter_popup;
}
add_action('wp_footer', 'popup_delay', 20);
Upvotes: 1
Views: 768
Reputation: 2675
If the anchor is doing what you want (the behaviour is already handled by the theme), you can trigger the click event of that anchor...
$(document).ready(function() {
setTimeout(function() {
$('a.etheme-popup').trigger('click');
},2000);
});
Upvotes: 1