এলিমেন্ট ফোকাস পেলে onfocus ইভেন্ট ট্রিগার হয়। নিচের কোড রান করে জাভাস্ক্রিপ্টে onfocus ইভেন্ট কীভাবে ইমপ্লিমেন্ট করা হয় তা শিখুন:
উদাহরণ
<!DOCTYPE html> <html> <body> <p>Write below:</p> <input type = "text" onfocus = "newFunc(this)"> <script> function newFunc(x) { x.style.background = "blue"; } </script> </body> </html>