I have builded a Trafic light on jquery but can not understand the code maybe there is an alternative for thhis code or can someone explain what does these functions means? the trafic ligths works good but the issue is with understanding the code/... especially ----opacity
<div class="trafficlight">
<div class="box">
<div class="red light" id="redlight">
</div>
<div class="orange light" id="orangelight">
</div>
<div class="green light" id="greenlight">
</div>
</div>
</div>
<script>
//lights
function redorange() {
$('#orangelight').css('opacity', 1)
};
function green() {
$('#redlight').css('opacity', 0.4)
$('#orangelight').css('opacity', 0.4)
$('#greenlight').css('opacity', 1)
clearInterval(first);
};
function orange() {
$('#orangelight').css('opacity', 1)
$('#greenlight').css('opacity', 0.4)
clearInterval(second);
};
function red() {
$('#redlight').css('opacity', 1)
$('#orangelight').css('opacity', 0.4)
clearInterval(third);
};
//var first = setInterval(redorange, 4000);
var second = setInterval(green, 5000);
var third = setInterval(orange, 8000);
var fourth = setInterval(red, 10000);
</script>
Aucun commentaire:
Enregistrer un commentaire