-1

I'm using Bootstrap4C UI, and I want to cancel the checked property of a particular element after some delay time. You can see the options I have tried on next example:

 $('.button_onoff').change(function()
 {
    console.log("pay_onoff change");

    /*(1). This works! */
    $(this).prop('checked',false);

    /*(2). This fails! */
    setTimeout(function(this) {
        $(this).prop('checked',false);
    }, 5000);

    /*(3). This fails! */
    $.wait(5000).$(this).prop('checked',false);

    /*(4). This fails! */
    $.wait(5000);
    $(this).prop('checked',false);

    /*(5). This fails! */
    $(this).delay(5000).prop('checked',false);

});

How can I use the this and delay function to accomplish my goal?

Shidersz
  • 15,614
  • 2
  • 15
  • 40
robspin
  • 637
  • 10
  • 25

1 Answers1

0

I found the answer

          var self = $(this);
          setTimeout(function() {
            self.prop('checked',false);
          }, 5000);
robspin
  • 637
  • 10
  • 25