Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> JavaScript

วิธีระบุว่าองค์ประกอบควรตรวจสอบ Vर्तनीและไวยากรณ์หรือไม่ใน HTML (spellcheck)

ใช้แอตทริบิวต์ spellcheck ตั้งค่า "true" หรือ "false" สำหรับ <input>, <textarea>, และองค์ประกอบที่ contenteditable

หมายเหตุ: ไม่ทำงานกับ input type="password"

ตัวอย่าง

<!DOCTYPE html>
<html>
  <body>
    Subject : <input type="text" name="sub" spellcheck="true">
    <p>Add an incorrect spelling for a word above and see what happens.</p>
    <p contenteditable="true" spellcheck="true">This is an editable conttent, with a spelling mistake. Click to edit.</p>
  </body>
</html>