Javascript: input-Element nachträglich einbinden - oninput und onblur funzen nicht
bearbeitet von@@Felix Riesterer
> Du notierst mit `input_1.onirgendwas = "ein String"`{:.language-javascript} im Grunde den Textinhalt eines HTML-Attributs gleichen Namens (hier *onirgendwas*). Was Du hier stattdessen tun solltest, ist einen passenden EventListener zu notieren:
Das gehört in jedes Stylesheet: 😏
```css
[onclick], [onfocus], [onblur], [oninput], [onchange], [onsubmit], [onerror] {
outline: medium solid orange;
--WARNING: 'use `addEventListener()` instead of `on*` attribute';
}
```
(Möglicherweise habe ich noch das ein oder andere `[on…]` vergessen.)
🖖 Live long and prosper
{:@en}
--
*“In my home, the America I love, the America I've written about, that has been a beacon of hope and liberty for 250 years, is currently in the hands of a corrupt, incompetent and treasonous administration. Tonight, we ask all who believe in democracy and the best of our American spirit, to rise with us, raise your voices against authoritarianism, and let freedom reign.”*{:@en}
— Bruce Springsteen, Manchester 2025-05-14