javascript - Change jQuery elements into div? -


how change window in window.changecolour call division id instead of window? thanks

window.changecolour = function(value) {     switch(value) {        case 'b':           color = "#ff0000";           break;        case 'r':           color = "#0000ff";           break;        case 'p':           color = "#ff00ff";           break;     }     document.body.style.backgroundcolor = color; } 

here html:

<div id= "genre">      <br><br>      <p>          <input type="radio" name="music" value="radio" onclick="changecolour('b')">blues          <br>          <input type="radio" name="music" value="radio" onclick="changecolour('r')">rock          <br>          <input type="radio" name="music" value="radio" onclick="changecolour('p')">pop          <br>     </p>  </div> 

if mean element id division, , change it's colour, here's get

demo

var div = document.getelementbyid("division") div.changecolour = function(value)     {     switch(value)      {         case 'b':             color = "#ff0000";         break;         case 'r':             color = "#0000ff";         break;         case 'p':             color = "#ff00ff";         break;     } div.style.backgroundcolor = color; } 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -