Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to use focus() Method Jquery ?

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 315
    Comment on it

    Hi Reader's,
      Welcome to FindNerd, today we are going to discuss how to use focus() Method in Jquery.


      Basically focus() Method event when an element gets focus with selected by mouse to it.
      So we can say that  focus event triggers the focus event.

    Note:The focus() Method is sent to an element when it gains focus. focus() Method is implicitly applicable to a inhibited set of elements, such as below element:
      a)<input>
      b)<a href>

    Syntax of focus() Method

    $(selector).focus()

    you can see below example:

    <!DOCTYPE html>
    <html>
    <head>
    
    <style>
    span {
        display: none;
    }
    </style>
    
    <!-- here add jquery library -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
    <script>
    $(document).ready(function(){
      //here call focus() method
        $("input").focus(function(){
            $("span").css("display", "inline").fadeOut(4000);
        });
    });
    </script>
    </head>
    <body>
    <!-- define a input box -->
    <input>
    
    <span>please enter your name</span>
    <!-- when you click in the input field then you will get focus with massage -->
    
    </body>
    </html>
    

     

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: