I'm trying to understand what each line of this code does e.g. why is the $
there and what does it do?, can anyone help?
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
<head>
<script>
i=1;
$(document).ready(function(){
$("button").click(function(){
if(i==1){
document.getElementById("tf1").setAttribute("fill", "transparent");
document.getElementById("tf2") .setAttribute("fill", "yellow");
i=2;
}else if (i==2){
document.getElementById("tf2").setAttribute("fill", "transparent");
document.getElementById("tf3") .setAttribute("fill", "green");
i=3;
} else if(i==3) {
document.getElementById("tf3").setAttribute("fill", "transparent");
document.getElementById("tf1").setAttribute("fill", "red") ;
i=1;
}
});
});
</script>