繁体   English   中英

检查按钮是否被按下

[英]Check if button has been pressed

我想添加一个 if 语句来检查用户是否未为我的程序定义。 它应该提醒:“没有更多的配置文件”。 问题是我的“likeId”一开始是未定义的,我第一次运行 function 时会收到警报。 我想知道我可以做一个 if 语句来检查某个按钮是否被准确地按下了一次。

这是我的代码:

if (localStorage.getItem('likeId') == "undefined"){
    alert("no more profiles to swipe")
}

我的代码应该是这样的:

if (localStorage.getItem('likeId') == "undefined" && Button has been clicked exactly one time){
        alert("no more profiles to swipe")
    }

只需在调用绑定到按钮的 function 时添加一个计数器。 然后检查buttonClickedCounter == 1是否对 go 很好。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM