javascript - Call an event from another element -
i have button a onclick = "alert(1);" and button b . how do, when click on button b , should call event on button a ? click b -> eventb -> eventa html: <button id="buttona"> button </button> <button id="buttonb"> button b </button> javascript: var = g('buttona'), b = g('buttonb'); function g(s) { return document.getelementbyid(s); } a.onclick = function() { alert('button clicked!'); }; b.onclick = function() { alert('button b clicked!'); a.click(); } live demo: http://jsfiddle.net/tapwr/1/ update: if button b inside iframe use top object reference window object of "parent" page. iframe code so: var b = document.getelementbyid('buttonb'); b.onclick = function() { alert('button b clicked!'); top.document.getelementbyid('buttona').click(); }