• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 129
  • Last Modified:

enter in jquery

Hello guys

I have a table with 20 rows, each row has a field that I insert a value.
When I insert a value into the field, I only update my table when the field is left.
I want to work with enter, when I click enter I want to focus a button.

How can I do this?
thanks
0
hidrau
Asked:
hidrau
  • 2
1 Solution
 
sonawanekiranCommented:
Check below example
<html>
<head>
<meta http-equiv="Content-Language" content="en-gb">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Kiran Test</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js" type="text/javascript"></script>

<script>
$(document).ready(function(){
    
     $("input").keypress(function (e) { 
        if ((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13)) {
            $("form").submit();
            return false;
        } else {
            return true;
        }
    });
      
  });
  


</script>
</head>

<body>
  <form action="http://www.google.com" method="get">
<input type="text" id="email"> <br />
<input type="text" id="name">
<input type="submit" id="1email" class="default">
</form>
</body>

</html>

Open in new window

0
 
hidrauAuthor Commented:
thanks very much
0
 
hidrauAuthor Commented:
0

Featured Post

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now