WordPress Blink Codes Doesn't Work

220 views Asked by At

I use codes with blink;

Jquery;

<script type="text/javascript">
    var blink = function(){
        $('#blinker').toggle();
    };
    $(document).ready(function() {
        setInterval(blink, 100);
    });
</script>

Page;

[full_column align="center"][su_button url="#basvuru" class="fancybox" background="#b21f30" size="6"] <div id="blinker">ÜCRETSİZ PROGRAMA BAŞVUR</div>[/su_button][/full_column]

Website: www.varsiteam.com

2

There are 2 answers

0
coder On

Try with :

<script type="text/javascript">

$(document).ready(function() {
       var blink = function(){
       $('#blinker').toggle();
    };

    setInterval(blink, 100);
});
</script>

If you look at console you will see this error:

Uncaught TypeError: undefined is not a function 

To fix that you have to put your function inside of $(document).ready event. When you call $('#blinker').toggle(); it tries to use jQuery object which is undefined if you not put it in $(document).ready event. That is how jQuery works.

2
RRikesh On

When you're working in WordPress, jQuery is loaded in a no-conflict mode.

So, you'll need to use jQuery and not $.

Your code should be:

var blink = function(){
  jQuery('#blinker').toggle();
};

Or if you want to wrap everything in your document ready event:

jQuery(document).ready(function($) {
  var blink = function(){
    $('#blinker').toggle();
  };
    setInterval(blink, 100);
});