Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> JavaScript
JavaScript
  1. การใช้งาน Event onfocusout ใน JavaScript

    Event onfocusout ทริกเกอร์เมื่อ Element สูญเสีย Focus (Blur) — Bubbles (ต่างจาก onblur ที่ไม่ Bubble) ตัวอย่างโค้ด <!DOCTYPE html> <html> <body> <p>Write below:</p> <p>After losing focus, the background color of input check will change.</p> &l

  2. การใช้งาน Event oninput ใน JavaScript

    Event oninput ทริกเกอร์ ทันทีที่ค่าใน Input เปลี่ยนแปลง (Real-time) ต่างจาก onchange ที่รอจน Blur/Enter ตัวอย่างโค้ด <!DOCTYPE html> <html> <body> <p>Write below:</p> <input type=text id=newInput oninput=inputFunc()> <p id=demo></p>

  3. การใช้งาน Event oninvalid ใน JavaScript

    Event oninvalid ทริกเกอร์เมื่อ Form Field ไม่ผ่าน Validation (HTML5 Constraint Validation) เช่น Required Field ว่าง, Pattern ไม่ตรง, Type ไม่ตรง — ก่อน Submit ตัวอย่างโค้ด <!DOCTYPE html> <html> <body> <script> function resetFunct() { alert(The form was r

  4. การใช้งาน Event onabort ใน JavaScript

    Event onabort ทริกเกอร์เมื่อ การโหลดรูปภาพถูกยกเลิก (Aborted) ก่อนโหลดเสร็จ เช่น User กด Stop, Network Error, หรือ JavaScript ยกเลิก ตัวอย่างโค้ด <!DOCTYPE html> <html> <body> <script> function abortFunc() { alert(Error - Loading of the image aborted);

  5. การใช้งาน Event onhashchange ใน JavaScript

    Event onhashchange ทริกเกอร์เมื่อ Hash Fragment (ส่วนหลัง #) ของ URL เปลี่ยนแปลง ใช้สำหรับ SPA Routing, Deep Linking, In-page Navigation ตัวอย่างโค้ด <!DOCTYPE html> <html> <body onhashchange=newFunc()> <button onclick=functionChange()>Click to change anchor</button

  6. การใช้งาน Event onpageshow ใน JavaScript

    Event onpageshow ทริกเกอร์เมื่อ หน้าแสดงขึ้น รวมถึงโหลดครั้งแรก และเมื่อRestore จาก Back-Forward Cache (bfcache) ตัวอย่างโค้ด <!DOCTYPE html> <html> <body onpageshow=newFunc()> <p>On first visit, a welcome message is visible.</p> <script> function

  7. การใช้งาน Event onbeforeunload ใน JavaScript

    Event onbeforeunload ทริกเกอร์ ก่อนที่หน้าจะ Unload ใช้แสดง Dialog ยืนยันให้ผู้ใช้ (เช่น คุณมีการเปลี่ยนแปลงที่ยังไม่ได้บันทึก ต้องการออกหรือไม่?) ตัวอย่างโค้ด <!DOCTYPE html> <html> <body onbeforeunload=return myFunction()> <a href=https://www.qries.com>Click to open

  8. การใช้งาน Event onpagehide ใน JavaScript

    Event onpagehide ทริกเกอร์เมื่อ ผู้ใช้ออกจากหน้า เช่น คลิกลิงก์ กด Back/Forward รีเฟรช ปิด Tab — รองรับ Back-Forward Cache (bfcache) ตัวอย่างโค้ด <!DOCTYPE html> <html> <body onpagehide=newFunc()> <p>Close the page and see what happens!</p> <script>

  9. การใช้งาน Event onscroll ใน JavaScript

    Event onscroll (หรือ scroll) ทริกเกอร์เมื่อ Scrollbar ถูกเลื่อน ภายใน Element ที่มี Overflow (รวม Window) ตัวอย่างโค้ด <!DOCTYPE html> <html> <head> <style> div { border: 2px solid blue; width: 300px; height: 100px; overflow: scrol

  10. การใช้งาน Event onresize ใน JavaScript

    Event onresize (หรือ resize) ทริกเกอร์เมื่อ ขนาด Browser Window เปลี่ยนแปลง ใช้ window.outerWidth/Height (ขนาด Browser ทั้งหมด) หรือ window.innerWidth/Height (ขนาด Viewport) ตัวอย่างโค้ด <!DOCTYPE html> <html> <head> <script> function resizeFunction() { v

  11. การทำงานกับ document.title ใน JavaScript

    Property document.title ใช้ อ่าน และ ตั้งค่า Title ของเอกสาร (แสดงบน Browser Tab/Title Bar) ตัวอย่างโค้ด <!DOCTYPE html> <html> <head> <title>Demo Title</title> </head> <body> <script> // อ่าน Title var x = document.title;

  12. การใช้งาน Event onunload ใน JavaScript

    Event onunload ทริกเกอร์เมื่อผู้ใช้ ปิดหน้า/แท็บ รีเฟรชหน้า หรือ นำทางไปหน้าอื่น ใช้สำหรับ Cleanup หรือ Analytics สุดท้าย ตัวอย่างโค้ด <!DOCTYPE html> <html> <body onunload=newFunc()> <p>Close the page and see what happens!</p> <p>This event may give un

  13. การทำงานกับ document.forms ใน JavaScript

    Property document.forms คืนค่า HTMLCollection ของ Element <form> ทั้งหมดในเอกสาร ใช้ .length เพื่อนับจำนวน ตัวอย่างโค้ด <!DOCTYPE html> <html> <head> <title>JavaScript Example</title> </head> <body> <h1>Employee Information</h1&

  14. วิธีสุ่มตัวเลข 1 ถึง 200 ใน JavaScript

    ใช้ Math.random() ร่วมกับ Math.floor() สูตรมาตรฐานสำหรับช่วง Min ถึง Max (Inclusive) สูตร Math.floor(Math.random() * (max - min + 1)) + min สำหรับ 1 ถึง 200: Math.floor(Math.random() * 200) + 1 ตัวอย่างโค้ด <!DOCTYPE html> <html> <body> <script> document.write(M

  15. Properties ของ window.screen Object ใน JavaScript

    Object window.screen (หรือ screen) ให้ข้อมูลเกี่ยวกับหน้าจอของผู้ใช้ นี่คือ Properties หลัก: Propertyความหมายค่าตัวอย่าง screen.widthความกว้างหน้าจอ (px)1920 screen.heightความสูงหน้าจอ (px)1080 screen.availWidthความกว้างพื้นที่ใช้งาน (ลบ Taskbar/Dock)1920 screen.availH

  16. การทำงานกับ document.images ใน JavaScript

    Property document.images คืนค่า HTMLCollection ของ Element <img> ทั้งหมดในเอกสาร ใช้ .length เพื่อนับจำนวน ตัวอย่างโค้ด <!DOCTYPE html> <html> <head> <title>JavaScript Example</title> </head> <body> <h1>TutorialsPoint Tutorials<

  17. การทำงานกับ document.links ใน JavaScript

    Property document.links คืนค่า HTMLCollection ของ Element ทั้งหมดที่มี href Attribute ได้แก่ <a> และ <area> ใช้ .length เพื่อนับจำนวน ตัวอย่างโค้ด <!DOCTYPE html> <html> <head> <title>JavaScript Example</title> </head> <body> <p

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