Add a Click event click
trigger button 1 to the button 2, even if you add a style to the button 1 display: none;
or visibility: hidden;
hide it can trigger.
<button type= "button" id= "BTN1" onclick= "alert (' I am the box for Button 1 ')" > button 1</button><button type= "button" id= " Btn2 "> button 2</button><script type=" Text/javascript "> Const BTN1 = document.getElementById (' btn1 '); Const BTN2 = document.getElementById (' btn2 '); Add Click event Btn2.addeventlistener to button 2 (' Click ', () + = {Btn1.onclick ();//button 2 Click to Trigger button 1 's onclick//btn1.click (); Button 2 Click to Trigger button 1 of the Click Effect as});</script>
JavaScript Click events/a button to trigger another button
This article from "Do not know not to ask" blog, please be sure to keep this source http://mazey.blog.51cto.com/12997993/1949469
JavaScript Click events/a button to trigger another button