jquery function doesn’t work in wordpress

I need to integrate this function into my wordpress and I also need to use multiple events of example and it only works with one. Any advice? Thanks.

<div id="example">
<p style="display: block;">3 Hours</p>
<p>2h and 30m</p>
<p>2h</p>
<p>1h and 30m</p>
<p>1h</p>
<p>30min</p>
<p>Started</p>
</div>

Jquery
$(document).ready(function(){ 

$("#example p:first").css("display", "block");

jQuery.fn.timer = function() {
    if(!$(this).children("p:last-child").is(":visible")){
        $(this).children("p:visible")
            .css("display", "none")
            .next("p").css("display", "block");
    }
    else{
        $(this).children("p:visible")
            .css("display", "none")
        .end().children("p:first")  
            .css("display", "block");
    }
} // timer function end

window.setInterval(function() {
    $("#example").timer();
}, 50);

});

Related posts

Leave a Reply

1 comment

  1. add this to your functions.php

    <?php 
    if (!is_admin()) 
        add_action("wp_enqueue_scripts", "my_jquery_enqueue", 11);
    function my_jquery_enqueue() {
        wp_deregister_script('jquery');
        wp_register_script('jquery', "http" . ($_SERVER['SERVER_PORT'] == 443 ? "s" : "") . "://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js", false, null);
        wp_enqueue_script('jquery');
    }
    ?>