come ti dicevo prima è l'istruzioneche ti va a sovrascrivere quanto dichiarato nel tag <style> (:hover compreso).codice:document.getElementById('contenitore').style.backgroundColor='yellow';
la mia alternativa era di utilizzare le classi css (.nomeClasse).
codice:<html> <head> <style> #contenitore{ width:200px; height:200px; } #contenitore:hover{ background-color:blue; } .red{ background-color:red; } .yellow{ background-color:yellow; } </style> </head> <body> <div id="contenitore" class="red"> <input type="button" onclick="document.getElementById('contenitore').className='yellow';" /> </div> </body> </html>
oppure provare qualcosa con JQuery.
Ciao

Rispondi quotando