Unstoppable Domains โ€” AI Assistant

Cannot assign a function to JavaScript event

SpaceshipSpaceship
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.
Unstoppable Domains โ€” AI StorefrontUnstoppable Domains โ€” AI Storefront
CatchedCatched
Escrow.com
Spaceship
Rexus Domain
CryptoExchange.com
Domain Recover
CatchDoms
DomainEasy โ€” Payment Flexibility
DomDB
  • The sidebar remains visible by scrolling at a speed relative to the pageโ€™s height.
Back