Scarlett Scarlett - 1 month ago 6
CSS Question

How to add randomness to the blink effect?

JS

<script>
(function blink() {
$('.demo').fadeOut(500).fadeIn(400, blink);
})();
</script>


CSS

.demo {
background: url('../res/logo.png') no-repeat;
width: 200px;
height: 200px;
margin-top: 355px;
margin-left: 855px;
}


How do i add randomness to this blinking effect?

Answer

This is as good as my answer can get until the question gets more specific:

(function blink() {
  $('.demo').fadeOut(Math.random()*500).fadeIn(Math.random()*400, blink); 
})();
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<span class="demo">I'm blinking!</span>

Comments