Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> JavaScript
JavaScript
  1. คุณสมบัติ shiftKey ของ Keyboard Event ใน JavaScript คืออะไร?

    บทนำ คุณสมบัติ shiftKey ของ Keyboard Event ใน JavaScript ใช้เพื่อตรวจสอบว่า Shift ถูกกดค้างอยู่หรือไม่ในขณะที่เกิดเหตุการณ์แป้นพิมพ์ (keydown, keyup, keypress) คุณสมบัตินี้จะคืนค่า true หาก Shift ถูกกดอยู่ และ false หากไม่ได้กด ตัวอย่างการใช้งาน ลองรันโค้ดด้านล่างเพื่อดูการทำงานของ shiftKey แบบเรี

  2. บทบาทของ Keyboard Event ctrlKey Property ใน JavaScript

    event.ctrlKey เป็น Property ของ KeyboardEvent (และ MouseEvent) ที่บอกว่า ปุ่ม Ctrl ถูกกดค้างอยู่หรือไม่ ในขณะที่ Event ถูก Trigger (true = กดอยู่, false = ไม่ได้กด) ตัวอย่าง: ตรวจจับ Ctrl + Key { const key = e.key; const ctrl = e.ctrlKey; const shift = e.shiftKey; const alt

  3. วิธีตั้งค่ารูปทรงขอบมุมขวาบน (Top-Right Border Radius) ด้วย JavaScript

    ใช้ Property style.borderTopRightRadius ของ Element เพื่อตั้งค่าความโค้งของมุมขวาบน (Top-Right Corner) แยกจากมุมอื่นๆ ได้ Syntax element.style.borderTopRightRadius = length | percentage | initial | inherit; ค่า: Length (px, em, rem, %), Percentage (ของ Width/Height ของ Element), Two Values (Horizont

  4. การแปลง [] (Empty Array) เป็น Boolean ใน JavaScript

    ใน JavaScript Empty Array [] แปลงเป็น Boolean ได้ true เพราะ Array เป็น Object และ Object ทุกตัว (ยกเว้น null) เป็น Truthy ตัวอย่าง true </script> Truthiness Table (ค่าที่เป็น Truthy / Falsy) ValueBoolean()Note [] (Empty Array)trueObject → Truthy [1,2] (Non-empty Array)trueObject → Truthy

  5. วิธีตั้งค่าสีขอบล่าง (Bottom Border Color) ด้วย JavaScript DOM

    ใช้ Property style.borderBottomColor ของ Element เพื่อตั้งค่าสีของขอบล่าง (Bottom Border) แยกจากขอบอื่นๆ ได้ Syntax element.style.borderBottomColor = color_value; color_value สามารถเป็น: Named Color (red, blue), Hex (#ff0000, #f00), RGB (rgb(255,0,0)), RGBA (rgba(255,0,0,0.5)), HSL, HSLA, transparen

  6. บทบาทของ clientX Mouse Event ใน JavaScript

    clientX เป็น Property ของ MouseEvent ที่คืนค่า พิกัดแนวนอน (X-coordinate) ของเมาส์ **สัมพันธ์กับ Viewport (บริเวณมองเห็นของเบราว์เซอร์)** ไม่รวม Scroll Offset ความแตกต่าง clientX vs pageX vs screenX Propertyจุดอ้างอิง (Origin)รวม Scroll?ใช้เมื่อไหร่ clientXViewport (Browser Window Visible Area)❌

  7. บทบาทของ clientY Mouse Event ใน JavaScript

    clientY เป็น Property ของ MouseEvent ที่คืนค่า พิกัดแนวตั้ง (Y-coordinate) ของเมาส์ **สัมพันธ์กับ Viewport (บริเวณมองเห็นของเบราว์เซอร์)** ไม่รวม Scroll Offset ความแตกต่าง clientY vs pageY vs screenY Propertyจุดอ้างอิง (Origin)รวม Scroll?ใช้เมื่อไหร่ clientYViewport (Browser Window Visible Area)

  8. -Infinity แปลงเป็น Number ใน JavaScript ยังไง?

    ใช้ Number() แปลง -Infinity เป็น Number จะได้ -Infinity (ค่าเดิม Identity) ตัวอย่างโค้ด <!DOCTYPE html> <html> <body> <p>Convert -Infinity to Number</p> <script> var myVal = -Infinity; document.write(Number : + Number(myVal)); // ผลลัพธ์: -

  9. บทบาทของ ctrlKey Mouse Event ใน JavaScript

    Property event.ctrlKey ใน Mouse Event บอกว่า ปุ่ม Ctrl ถูกกดค้างอยู่หรือไม่ ขณะที่ Mouse Event เกิดขึ้น ตัวอย่างโค้ด <!DOCTYPE html> <html> <body onmousedown=funcCtrlKey(event)> <div>Press and hold CTRL key and then click here.</div> <script> func

  10. บทบาทของ pageX Mouse Event ใน JavaScript

    Property event.pageX ใน Mouse Event คืนค่า Horizontal Coordinate (X) ของ Mouse Pointer เทียบกับ Document 全体 (รวม Scroll) ตัวอย่างโค้ด <!DOCTYPE html> <html> <body> <p onclick=coordsFunc(event)>Click here to get the x (horizontal) and y (vertical) coordinates of the mou

  11. บทบาทของ pageY Mouse Event ใน JavaScript

    Property event.pageY ใน Mouse Event คืนค่า Vertical Coordinate (Y) ของ Mouse Pointer เทียบกับ Document 全体 (รวม Scroll) ตัวอย่างโค้ด <!DOCTYPE html> <html> <body> <p onclick=coordsFunc(event)>Click here to get the x (horizontal) and y (vertical) coordinates of the mouse

  12. -Infinity แปลงเป็น String ใน JavaScript ยังไง?

    ใช้ String() แปลง -Infinity เป็น String จะได้ -Infinity ตัวอย่างโค้ด <!DOCTYPE html> <html> <body> <p>Convert -Infinity to String</p> <script> var myVal = -Infinity; document.write(String: + String(myVal)); // ผลลัพธ์: -Infinity </sc

  13. Null แปลงเป็น String ใน JavaScript ยังไง?

    ใช้ String() แปลง null เป็น String จะได้ null (String ตัวอักษร 4 ตัว) ตัวอย่างโค้ด <!DOCTYPE html> <html> <body> <p>Convert null to String</p> <script> var myVal = null; document.write(String: + String(myVal)); // ผลลัพธ์: null </scr

  14. Null แปลงเป็น Boolean ใน JavaScript ยังไง?

    ใช้ Boolean() แปลง null เป็น Boolean จะได้ false ตัวอย่างโค้ด <!DOCTYPE html> <html> <body> <p>Convert null to Boolean</p> <script> var myVal = null; document.write(Boolean: + Boolean(myVal)); // ผลลัพธ์: false </script> </bo

  15. บทบาทของ altKey Mouse Event ใน JavaScript

    Property event.altKey ใน Mouse Event บอกว่า ปุ่ม Alt ถูกกดค้างอยู่หรือไม่ ขณะที่ Mouse Event เกิดขึ้น (click, mousedown, mousemove, etc.) ตัวอย่างโค้ด <!DOCTYPE html> <html> <body onmousedown=funcAltKey(event)> <div>Press and hold ALT key and then click here.</div&g

Total 5941 -คอมพิวเตอร์  FirstPage PreviousPage NextPage LastPage CurrentPage:235/298  20-คอมพิวเตอร์/Page Goto:1 229 230 231 232 233 234 235 236 237 238 239 240 241