Reputation: 13
If I have searchbox.onsubmit = function(){ //Function here }
and I wanted searchbtn.onclick
to trigger the same function, how would I go about doing that?
Upvotes: 1
Views: 44
Reputation: 2258
This will work too.
var myFunction = function() {
alert("myfunc");
}
searchbox.addEventListener("submit", myFunction);
searchbtn.addEventListener("click", myFunction);
Upvotes: 0
Reputation: 1782
Have you tried...
function handleEvent(){
}
searchbox.onsubmit = handleEvent;
searchbtn.onclick = handleEvent;
Upvotes: 2