HTML-এ এলিমেন্ট ফোকাস পেলে স্ক্রিপ্ট চালাতে onfocus অ্যাট্রিবিউট ব্যবহার করা হয়।
উদাহরণ
নিচের কোডটি চালিয়ে onfocus অ্যাট্রিবিউটের ব্যবহার দেখতে পারেন:
<!DOCTYPE html> <html> <body> <p>Enter subject name below,</p> Subject: <input type = "text" id = "sname" onfocus = "display(this.id)"> <br> <script> function display(val) { document.getElementById(val).style.background = "blue"; } </script> </body> </html>