Search code examples
javascriptonfocus

Pass onfocus on onmouseenter event in javascript


I have a requirement where when a user hover through a section, the section gets active without clicking the mouse button.

Example: 2 text boxes open side by side on a web browser, user hovers on one of them and start wirting startight away without even clicking the mouse.

Can we do this by calling onfocus() when the mouse does a onmouseenter()?


Solution

  • You can use this code:

    $("input").mouseenter(function() {
        $(this).focus();
    });
    

    http://jsfiddle.net/zfggtf3b/