นี่คือโค้ดสำหรับการล้างค่าในช่องกรอกข้อมูล (Input Field) เมื่อผู้ใช้คลิก Focus เข้าไป โดยใช้ JavaScript inline
ตัวอย่าง
<!DOCTYPE html> <html> <head> <h1>Clearing an input field on focus example</h1> <input type="text" onfocus="this.value=''" value="Some random text..."> <h2>Click on the above field to clear its value</h2> </body> </html>
ผลลัพธ์
โค้ดด้านบนจะแสดงผลดังนี้ −

เมื่อคลิกที่ช่อง ค่าภายในจะถูกล้าง −
