lundi 28 septembre 2015

Javascript changing stylsheets with if statements

Previous post was too long so trying to shorten it up.. Basically having trouble with the function, at least thats what I think the problem is. The aim is for when the volume or slider is over 50 the color turns red, and when its under 50 it turns green.

Javascript:

    function changeColor(sheet) {
    document.getElementById("Green").setAttribute('href', sheet);
    document.getElementById("Red").setAttribute('href', sheet);

    if (mediaClip.volume < 0.5)
    {
      changeColor("styleSheets/Green.css");
    }
  else
    {
      changeColor("styleSheets/Red.css");
    }

Html:

<input type="range" onchange="setVolume();changeColor()" id='volume1' min=0 max=1 step=0.01 value='1'/>

All feedback is appreciated, would be great to get this working by the end of the night. Please keep in mind that I'm very new to coding so the simpler the better.

Aucun commentaire:

Enregistrer un commentaire