Cannot assign a function to JavaScript event

NamecheapNamecheap
Watch

vilstewart

Established Member
Impact
1
Alright, well I am trying to assign a function to a JavaScript Event for a retrieved element.

I will explain with code first :

Code:
window.onload = function() {

    var divBox = document.getElementById(someid)
    var divBox.onclick = someOtherFunction(arg,arg)

}

function someOtherFunction(arga,argb){
    var anotherDiv = document.getElementById(someid)
        anotherDiv.style.color='blue'
}

If I attempt to do something similar to the above code, it executes 'someOtherFunction' rather than just setting the onclick event to the function with the proper arguments that I need to send it.

Any suggestions ? Thanks a lot guys :)
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
CatchedCatched

We're social

Escrow.com
Spaceship
Rexus Domain
CryptoExchange.com
Domain Recover
CatchDoms
DomDB
NameFit
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back