我下面有HTML控件,并且希望在单击后有所延迟,以便用户不会意外或有意再次单击它-

 更新同步值

<a href="Javascript:main.ManualCommand.perform( 'command here' )"><FONT size=3 COLOR = White> UPDATE SYNCHRONIZED VALUES</FONT></A>

最佳答案

在您的main.ManualCommand.perform中添加这样的内容

var lastClick = 0;
var delay = 1000; // 1 second

function perform(command) {
    if (Date.now() < lastClick + delay) {
        // can't click yet
        return;
    }
    lastClick = Date.now(); // set the last click to this moment
    // perform your actual logic here
}

10-07 14:52