shershen shershen - 2 years ago 117
jQuery Question

How to make button blinking infinite, but with possibility to stop at anytime

I need to make button to start blinking after some other elemment trigered it, for example checking the checkbox - see the code below:

<label>I agree with the terms</label>
<input class="some_check" type="checkbox" id="Signed">
<button class="buttonstyle" name="buttonNext" onClick="nextChoose('NEXT')" disabled>Proceed!</button>

Blinking must be infinite until:

  1. user clicks the button or

  2. unchecks the checkbox.

I know there's
method in jQuery UI, but it's time-limited
and if I loop it through the callback, how than I can break it to return button in a previous state?

Answer Source

Maybe your looking for something like this THIS FIDDLE


#click, #btn {margin: 20px;}


var timer;

$("#blink").on('change', function() {
    if ($("#blink").is(':checked')) {
    } else {

$("#btn").click(function() {
    $("#blink").attr('checked', false);

function blinking(elm) {
    timer = setInterval(blink, 10);
    function blink() {
        elm.fadeOut(400, function() {


<input type="checkbox" id="blink"/>
<input type="button" value="CLICK ME" id="btn" />
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download