I want to write some JavaScript that will change the onmousedown of a div at runtime. So on load a mouse down on the div will do one thing and if a JavaScript function is called a mouse down on the div will do something else. Is this possible?
You can just assign the onMouseDown property.
document.getElementById('myDiv').onmousedown = function() {
alert('New mouse down handler.');
};
Keep in mind that javascript properties are case-sensitive. "onmousedown" is all lower-case.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With