ใครเก่ง java script ช่วยหน่อยครับ ผมจะดัดแปลง Code นี้ให้ตามโจทย์ของผมยังไง

เริ่มโดย OriginaL, 02 มกราคม 2012, 22:00:58

หัวข้อก่อนหน้า - หัวข้อถัดไป

0 สมาชิก และ 1 ผู้มาเยือน กำลังดูหัวข้อนี้

OriginaL

ตัวอย่างด้านล่าง เป็น Code เปลี่ยนสีพื้นหลังและตัวอักษรตามเวลา

<SCRIPT>
<!--

var now = new Date();
var hours = now.getHours();
var psj=0;

//18-19 night
if (hours > 17 && hours < 20){
document.write('<body bgcolor="orange" text="green">')
}

//20-21 night
if (hours > 19 && hours < 22){
document.write('<body bgcolor="orangered" text="red">')
}

//22-4 night
if (hours > 21 || hours < 5){
document.write('<body bgcolor="black" text="orange">')
}

//9-17 day
if (hours > 8 && hours < 18){
document.write('<body bgcolor="deepskyblue" text="blue">')
}

//7-8 day
if (hours > 6 && hours < 9){
document.write('<body bgcolor="skyblue" text="deepskyblue">')
}

//5-6 day
if (hours > 4 && hours < 7){
document.write('<body bgcolor="steelblue" text="skyblue">')
}


//-->
</SCRIPT>


ขอบคุณที่มาจาก http://www.codetukyang.com/java/time/code/code9.htm


แต่ผมอยากจะให้สีพื้นหลังและอักษรมันเปลี่ยนตามวันครับ เช่น
วันจันทร์  สีแดง
อังคาร สีเหลือง

จนถึงวันอาทิตย์  แล้วมันก็จะวนอยู่แบบนี้อะครับ


ขอบคุณมากครับ

medzmay


var d=new Date();
window.onload=function(){
   if(d.getDay()==0){ //0=วันอาทิตย์ 1= วันจันทร์.............................
      document.body.style.backgroundColor="#000000"; // ใส่ค่าสีนั้นๆ
   }
};


ตามนี้เลยครับ
[direct=https://propertytrend.co]รีวิวคอนโด[/direct]
[direct=https://roadnroll.co]รีวิวรถยนต์ มอเตอร์ไซค์[/direct]
[direct=https://www.ennxo.com]ขายของมือสอง[/direct]
[direct=https://www.ennxo.com/computer/laptop]โน๊ตบุ๊คมือสอง[/direct]
[direct=https://propertytrend.co/article/the-issara-sathorn]รีวิว ดิ อิสสระ สาทร[/direct]

OriginaL

อ้างถึงจาก: medzmay ใน 02 มกราคม 2012, 22:22:40

var d=new Date();
window.onload=function(){
   if(d.getDay()==0){ //0=วันอาทิตย์ 1= วันจันทร์.............................
      document.body.style.backgroundColor="#000000"; // ใส่ค่าสีนั้นๆ
   }
};


ตามนี้เลยครับ

ขอบคุณครับ