জাভাস্ক্রিপ্ট focus() মেথড একটি এলিমেন্টে ফোকাস করার জন্য ব্যবহৃত হয়, শুধু যদি সেই এলিমেন্ট ফোকাস করা যায়।
উদাহরণ
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>Document</title> <style> body { font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; } .sample { font-size: 18px; font-weight: 500; } </style> </head> <body> <h1>জাভাস্ক্রিপ্ট focus()</h1> <input type="text" class="sample"></input> <button class="Btn">এখানে ক্লিক করুন</button> <h3> উপরের বাটনে ক্লিক করলে ইনপুট ফিল্ডে ফোকাস হবে </h3> <script> let sampleEle = document.querySelector(".sample"); document.querySelector(".Btn").addEventListener("click", () => { sampleEle.focus(); }); </script> </body> </html>আউটপুট

“এখানে ক্লিক করুন” বাটনে ক্লিক করলে −
