How to hang two handlers on one event, but pass one handler as a parameter to the other?
-
let w3 = 75; let out = ''; function t3() { this.style.width = w3 + 'px'; w3+=5; } function t33(func) { out = func; document.querySelector('.out-3').innerHTML = out; } // ваше событие здесь!!! document.querySelector('.div-3').addEventListener('click', t3, t33(t3));<a href="http://codepen.io/orgeniuss/pen/zYBxMEv"></a>
JavaScript Anonymous, Apr 4, 2019 -
Can't you do that?
let w3 = 75;
let out = '';
function t3() {
this.style.width = w3 + 'px';
w3+=5;
t33(w3);
}
function t33(func) {
out = func;
document.querySelector('.out-3').innerHTML = out;
}
// ваше событие здесь!!!
document.querySelector('.div-3').addEventListener('click', t3);Anonymous
1 Answers
Your Answer
To place the code, please use CodePen or similar tool. Thanks you!