Archives
Trending
Support
Login
clear text
XML
Django
JavaScript
MATLAB
C
C++
C#
Python
SQL
Shell
Bash
Markdown
YAML
JSON
HTML
CSS
PHP
Java
Ruby
Go
Rust
Swift
Kotlin
Arduino
TypeScript
Perl
Autohotkey
Lua
SQF
R
Scala
Haskell
Groovy
Dart
Clojure
VB.NET
Objective-C
PowerShell
Bash
CoffeeScript
Verilog
// Javascript let mioBottone = document.getElementById("mio-bottone"); let mioDiv = document.getElementById("mio-div"); let mioParagrafo = document.getElementById("mio-paragrafo"); mioParagrafo.addEventListener("click", gestioneEventi); mioBottone.addEventListener("click", gestioneEventi); // mioBottone.addEventListener("mouseover", eventoBottone); // mioBottone.addEventListener("mouseout", eventoBottone); function stampaNelDiv(ilDiv, testoDaScrivereNelDiv) { ilDiv.innerHTML = testoDaScrivereNelDiv; } function gestioneEventi(mioEvento) { mioDiv.style.color = ""; let tipoEvento = mioEvento.type; let elementoDellEvento = mioEvento.target; if (tipoEvento === "click") { if (elementoDellEvento.id === "mio-paragrafo") { // e' stato il paragrafo! stampaNelDiv(mioDiv, "Hai cliccato sul paragrafo con id = " + elementoDellEvento.id) // mioDiv.innerHTML = "Hai cliccato sul paragrafo con id = " + elementoDellEvento.id; } else if (elementoDellEvento.id === "mio-bottone") { // e' stato il bottone! mioDiv.innerHTML = "Hai cliccato sul bottone con id = " + elementoDellEvento.id; } else { // non so chi sia stato! :-( mioDiv.innerHTML = "Non so quale elemento abbia attivato l'evento click!"; } } else if (tipoEvento === "mouseover" || tipoEvento === "mouseout") { mioDiv.innerHTML = tipoEvento; } else { mioDiv.innerHTML = "Evento sconosciuto"; mioDiv.style.color = "red"; } // document.getElementById("mio-div").innerHTML = tipoEvento; } // HTML
Lezione 7 Novembre
Start
Clicca qui
Mark as private (unlisted)
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
everlasting (like CCCP)