Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> JavaScript
JavaScript
  1. Infinity แปลงเป็น Number ใน JavaScript ยังไง?

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

  2. NaN แปลงเป็น Boolean ใน JavaScript ยังไง?

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

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

    Event onreset ทริกเกอร์เมื่อ Form ถูก Reset (กด <input type=reset> หรือเรียก form.reset()) ตัวอย่างโค้ด <!DOCTYPE html> <html> <body> <script> function resetFunct() { alert(The form was reset); } </script> <form onreset=resetF

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

    Event onsearch ทริกเกอร์เมื่อ User กด Enter หรือกดปุ่ม Clear (✕) ใน <input type=search> ตัวอย่างโค้ด <!DOCTYPE html> <html> <body> <p>Write what you want to search below and press ENTER.</p> <input type=search id=newInput onsearch=searchFunc()>

  5. Event ใดเกิดเมื่อ Element กำลังถูก Drag ใน JavaScript?

    Event ondrag ทริกเกอร์ ซ้ำๆ ตลอดการ Drag (High Frequency) ระหว่างที่ User จับ Element อยู่และเคลื่อนย้าย ตัวอย่างโค้ด <!DOCTYPE HTML> <html> <head> <style> .drag { float: left; width: 100px; height: 35px; border: 2px dashed #876587; margin: 15px; padding: 10px; }

  6. Null แปลงเป็น Number ใน JavaScript ยังไง?

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

  7. Event ใดเกิดเมื่อเริ่ม Drag Element ใน JavaScript?

    Event ondragstart ทริกเกอร์เมื่อ เริ่มการ Drag Element (จับเมาส์/สัมผัสแล้วเคลื่อนย้าย) — จุดสำคัญที่สุดคือ ตั้งค่า DataTransfer ตัวอย่างโค้ด <!DOCTYPE HTML> <html> <head> <style> .drag { float: left; width: 100px; height: 35px; border: 2px dashed #876587; margin

  8. Event ใดเกิดเมื่อ Drag Element เสร็จสิ้นใน JavaScript?

    Event ondragend ทริกเกอร์เมื่อ การ Drag จบสิ้นสุด (ปล่อยเมาส์/ปล่อยนิ้ว) ไม่ว่าจะ Drop สำเร็จหรือยกเลิก ตัวอย่างโค้ด: Drag and Drop 完整流程 <!DOCTYPE HTML> <html> <head> <style> .drag { float: left; width: 100px; height: 35px; border: 2px dashed #876

  9. วิธีเปลี่ยนค่า Attribute ใน JavaScript

    สามารถเปลี่ยนค่า Attribute ของ Element ได้โดยตรงผ่าน Property หรือใช้ setAttribute() ตัวอย่างโค้ด <!DOCTYPE html> <html> <body> <img id=HTML5 src=https://www.tutorialspoint.com/html5/images/html5-mini-logo.jpg width=200 height=150> <script> // วิธี 1: P

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

    Event onblur ทริกเกอร์เมื่อ Element สูญเสีย Focus — ไม่ Bubble (ต่างจาก focusout) ตัวอย่างโค้ด <!DOCTYPE html> <html> <body> <p>Write below:</p> <input type=text onblur=newFunc(this)> <script> function newFunc(a) { a.style.backgr

  11. การใช้งาน Event onfocus ใน JavaScript

    Event onfocus ทริกเกอร์เมื่อ Element ได้รับ Focus — ไม่ Bubble (ต่างจาก focusin) ตัวอย่างโค้ด <!DOCTYPE html> <html> <body> <p>Write below:</p> <input type=text onfocus=newFunc(this)> <script> function newFunc(x) { x.style.backgr

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

    Event onfocusin ทริกเกอร์เมื่อ Element ได้รับ Focus — Bubbles (ต่างจาก onfocus ที่ไม่ Bubble) ตัวอย่างโค้ด <!DOCTYPE html> <html> <body> <p>Write below:</p> <input type=text onfocusin=newFunc(this)> <script> function newFunc(x) {

  13. NodeName Property ใน JavaScript HTML DOM คืออะไร?

    Property nodeName คืนค่า ชื่อของ Node เป็น String ตัวพิมพ์ใหญ่สำหรับ HTML Elements ตัวอย่างโค้ด <!DOCTYPE html> <html> <body> <h1 id=id1>Tutorials</h1> <p id=id2>Demo Content</p> <p id=id3></p> <p id=id4></p> &l

  14. NodeValue Property ใน JavaScript HTML DOM คืออะไร?

    Property nodeValue ใช้ อ่าน/ตั้งค่า ค่าของ Node ใช้กับ Node Types ที่มีค่า: Text, Comment, CDATASection, Attr (Deprecated) — ไม่ทำงานกับ Element Node ตัวอย่างโค้ด <!DOCTYPE html> <html> <body> <p>Get the node value</p> <button>Demo Button Text</butto

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