I have to get 3 rectangular, colored boxes with CSS (works so far), that change color when they are clicked (through Java, this part does not work).
The CSS is as follows:
#rood{
width:20px;
height:20px;
background-color:rgb(255, 0, 0);
position:absolute;
top:10px;
left:640px;
cursor:pointer;
}
#blauw{
width:20px;
height:20px;
background-color:rgb(0, 0, 255);
position:absolute;
top:40px;
left:640px;
cursor:pointer;
}
#groen{
width:20px;
height:20px;
background-color:rgb(0, 255, 0);
position:absolute;
top:70px;
left:640px;
cursor:pointer;
}
These are, respectively, a red, green and blue box.
The intention is that when the box on top (red in this example) is clicked, it changes to the color at the bottom, the middle one becomes red and the bottom one becomes the color the middle one was, in other words, each color has to move down one space, except for the one at the bottom, which goes to the top.
This has to work, no matter which box you click on.
So I got started on the Java, but this is where it gets complicated, as I have never worked with Java before, and my teacher tells us to Google it and look on w3schools. Sadly, I can't find any solutions here.
This is the code I have so far:
if($('#rood').css('background-color')=='rgb(255, 0, 0)')
{
('#rood').css('background-color')=='rgb(0, 255, 0)')
}
else
{
if($('#rood').css('background-color')=='rgb(0, 255, 0)')
{
}
else
{
if($('#rood').css('background-color')=='rgb(0, 0, 255)')
{
}
}
}
I have tried solving it with Jquery, with every Java command I could find, but I'm at a total loss. Anyone who could offer some help to at least get me started on finding a solution?
Much appreciated.
Jens

New Topic/Question
Reply


MultiQuote









|