+ 1
help!
is there any method to make a button clicked rather than calling a function for each button? i had try the following code but doesnt work if(document.getElementById("button1"). clicked == true){ alert("bla, bla, bla"); }
4 Réponses
+ 4
<button id="btn" onclick={alert ("bla,bla,bla")}>button1</button>
// other elements can call onclick() or click () to trigger the button event. Some browsers use onclick, some use click functions
var btn = document.getElementById('btn');
if(typeof btn.click == 'function') btn.click()
else if(typeof btn.onclick == 'function') btn.onclick()
Try and tell us the code is work for you or not. :)
0
onclick is very easy with function and window.onclick='' or write in google w3school onclick function
0
beacause is bad onclick in html is better in pure.js