[Vuejs]-How to delay a function excecution

0👍

setTimeout takes milliseconds, so you set timout for 180ms, it is too short, try 3000 for example. Here a small jsfiddle example.

https://jsfiddle.net/ShinShil/5fw2c63o/

var timeout;
$('#click').click(function() {
    clearTimeout(timeout);
  timeout = setTimeout(setText, 3000);
});

function setText() {
    $('#text').append('text');
}

Leave a comment