Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I'm in the middle of a project where I need to show a popup when two or more buttons have been clicked.(我在一个项目的中间,当单击两个或更多按钮时,需要显示一个弹出窗口。)

Does anyone know how to do that?(有谁知道这是怎么做到的吗?)   ask by Ana Fernández translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
377 views
Welcome To Ask or Share your Answers For Others

1 Answer

Try the javascript below.(试试下面的javascript。)

var clicks = 0; var buttons = document.getElementsByTagName("button"); for (i = 0; i < buttons.length; i++){ buttons[i].addEventListener("click", function(){ clicks++; if(clicks >= 2){ alert('Pop-up. ' + clicks + ' clicks have been recorded.'); } }); } <button>Button 1</button> <button>Button 2</button> <button>Button 3</button>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...