Focus cursor to a hidden field

html, javascript, jquery

Solution

You can't focus on a hidden element.

You can use `opacity: 0` instead of `display: none` and you will be able to focus on the element.

Problem

I have this script where i want cursor to be focused on hidden field but it doesn't seem to be working . When i make the field visible it seems to work. ``` $(document).ready(function(){ $("#card_number").focus(); $("#card_number").keypress(function() { alert($("#card_number").val()); }); }); ```

Original source