22. september 2003 - 13:22
Der er
12 kommentarer og 1 løsning
farver skifter
Hej. Jeg har følgende kode: <table width=400 height=400> <tr> <td bgcolor=red width=50%> Rød </td> <td bgcolor=yellow width=50%> Gul </td> </tr> <tr> <td bgcolor=green> Grøn </td> <td bgcolor=blue> Blå </td> </tr> </table> Der er 4 farver og det skal nu være sådan at farven skifter når man holder musen indover. Det røde, skal blive blå, det gule skal blive rød, det grønne skal blive gul og det blå skal blive grøn. Er der nogen der har en de til hvordan man gør dette?
Annonceindlæg fra Cognizant
Agentic AI kræver mere end teknologi
De fleste virksomheder har efterhånden bevist, at AI virker.
Pilotprojekter leverer resultater. Medarbejdere bruger generative AI-værktøjer. Nye use cases dukker op på tværs af organisationen.
22. september 2003 - 13:30
#1
<table width=400 height=400> <tr> <td bgcolor=red width=50% onmouseover="this.style.background='blue'" onmouseout="this.style.background='red'"> Rød </td> <td bgcolor=yellow width=50% onmouseover="this.style.background='red'" onmouseout="this.style.background='yellow'"> Gul </td> </tr> <tr> <td bgcolor=green onmouseover="this.style.background='yellow'" onmouseout="this.style.background='green'"> Grøn </td> <td bgcolor=blue onmouseover="this.style.background='green'" onmouseout="this.style.background='blue'"> Blå </td> </tr> </table>
22. september 2003 - 13:31
#2
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <title>Untitled</title> <script language="JavaScript"> function colorChanger(id, color) { //document.getElementById("1").style.color = 'ff0000'; document.getElementById("1").style.backgroundColor=color; } </script> </head> <body> <table width=400 height=400> <tr> <td bgcolor=red width=50% id="1" onmouseover="colorChanger(this.id, 'blue');"> Rød </td> <td bgcolor=yellow width=50% id="2" onmouseover="colorChanger(this.id, 'red');"> Gul </td> </tr> <tr> <td bgcolor=green id="3" onmouseover="colorChanger(this.id, 'yellow');"> Grøn </td> <td bgcolor=blue id="1" onmouseover="colorChanger(this.id, 'green');"> Blå </td> </tr> </table> </body> </html> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <title>Untitled</title> <script language="JavaScript"> function colorChanger(id, color) { //document.getElementById("1").style.color = 'ff0000'; document.getElementById("1").style.backgroundColor=color; } </script> </head> <body> <table width=400 height=400> <tr> <td bgcolor=red width=50% id="1" onmouseover="colorChanger(this.id, 'blue');"> Rød </td> <td bgcolor=yellow width=50% id="2" onmouseover="colorChanger(this.id, 'red');"> Gul </td> </tr> <tr> <td bgcolor=green id="3" onmouseover="colorChanger(this.id, 'yellow');"> Grøn </td> <td bgcolor=blue id="1" onmouseover="colorChanger(this.id, 'green');"> Blå </td> </tr> </table> </body> </html> //>Rune
22. september 2003 - 13:31
#3
Hov, en for meget! *G* Den skal kun se således ud: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <title>Untitled</title> <script language="JavaScript"> function colorChanger(id, color) { //document.getElementById("1").style.color = 'ff0000'; document.getElementById("1").style.backgroundColor=color; } </script> </head> <body> <table width=400 height=400> <tr> <td bgcolor=red width=50% id="1" onmouseover="colorChanger(this.id, 'blue');"> Rød </td> <td bgcolor=yellow width=50% id="2" onmouseover="colorChanger(this.id, 'red');"> Gul </td> </tr> <tr> <td bgcolor=green id="3" onmouseover="colorChanger(this.id, 'yellow');"> Grøn </td> <td bgcolor=blue id="1" onmouseover="colorChanger(this.id, 'green');"> Blå </td> </tr> </table> </body> </html> //>Rune
22. september 2003 - 13:32
#4
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>404175</title> <script language="JavaScript" type="text/javascript"> function swap(tr, col){ tr.style.backgroundColor = col; } </script> </head> <body> <table width=400 height=400> <tr> <td style="background-color: red; width: 50%;" onMouseOver="swap(this,'blue');" onMouseOut="swap(this,'red');"> Rød</td> <td style="background-color: yellow; width: 50%;" onMouseOver="swap(this,'red');" onMouseOut="swap(this,'yellow');"> Gul</td> </tr> <tr> <td style="background-color: green; width: 50%;" onMouseOver="swap(this,'yellow');" onMouseOut="swap(this,'green');"> Grøn</td> <td style="background-color: blue; width: 50%;" onMouseOver="swap(this,'green');" onMouseOut="swap(this,'blue');"> Blå</td> </tr> </table> </body> </html>
22. september 2003 - 13:33
#5
AGH den bliver ved! <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <title>Untitled</title> <script language="JavaScript"> function colorChanger(id, color) { //document.getElementById("1").style.color = 'ff0000'; document.getElementById(id).style.backgroundColor=color; } </script> </head> <body> <table width=400 height=400> <tr> <td bgcolor=red width=50% id="1" onmouseover="colorChanger(this.id, 'blue');"> Rød </td> <td bgcolor=yellow width=50% id="2" onmouseover="colorChanger(this.id, 'red');"> Gul </td> </tr> <tr> <td bgcolor=green id="3" onmouseover="colorChanger(this.id, 'yellow');"> Grøn </td> <td bgcolor=blue id="4" onmouseover="colorChanger(this.id, 'green');"> Blå </td> </tr> </table> </body> </html> *G* //>Rune
22. september 2003 - 13:47
#6
>>rune -- hvorfor bruger du ikke id'er med et bogstav først, så du helt undgår eventuelle problemer med javascript ?-) -- som du har lavet det er der ikke nogen problemer, men der kunne være andre ting som skulle gøres med cellerne, og så ville der kunne være problemer !-)
22. september 2003 - 13:50
#7
Tjaaa det var lige den løsning jeg først kom på :) //>Rune
22. september 2003 - 14:07
#8
hmm.. Jeg havde mere tænkt mig at alle felterne skulle skifte farve ved mouseover på et af dem.
22. september 2003 - 14:20
#9
<script type="text/javascript"> function changeBackground(typ){ //alert('Hej'); td = document.getElementById('red'); td.style.backgroundColor = (typ=='in')?'blue':'red'; td = document.getElementById('yellow'); td.style.backgroundColor = (typ=='in')?'red':'yellow'; td = document.getElementById('green'); td.style.backgroundColor = (typ=='in')?'yellow':'green'; td = document.getElementById('blue'); td.style.backgroundColor = (typ=='in')?'green':'blue'; } </script> <table width=400 height=400> <tr> <td bgcolor=red width=50% id="red" onmouseover="changeBackground('in')" onmouseout="changeBackground('out')"> Rød </td> <td bgcolor=yellow width=50% id="yellow" onmouseover="changeBackground('in')" onmouseout="changeBackground('out')"> Gul </td> </tr> <tr> <td bgcolor=green id="green" onmouseover="changeBackground('in')" onmouseout="changeBackground('out')"> Grøn </td> <td bgcolor=blue id="blue" onmouseover="changeBackground('in')" onmouseout="changeBackground('out')"> Blå </td> </tr> </table>
22. september 2003 - 14:24
#10
Fedt nok, roenving Hvis du lige ligger et svar så får du lige de points. :)
22. september 2003 - 14:32
#11
Velbekomme '-)
22. september 2003 - 14:35
#12
Takker og lukker ;)
22. september 2003 - 14:35
#13
-- og jeg takker for points ;~}
Vi tilbyder markedets bedste kurser inden for webudvikling