Jquery: how to trigger click event on pressing enter key -


i need execute button click event upon pressing key enter.

as @ moment event not firing.

please me syntax if possible.

$(document).on("click", "input[name='butassignprod']", function () {    //all action }); 

this attempt fire click event on enter.

$("#txtsearchprodassign").keydown(function (e) {   if (e.keycode == 13) {     $('input[name = butassignprod]').click();   } }); 

try out this....

$('#txtsearchprodassign').keypress(function (e) {  var key = e.which;  if(key == 13)  // enter key code   {     $('input[name = butassignprod]').click();     return false;     } });    

$(function() {      $('input[name="butassignprod"]').click(function() {      alert('hello...!');    });      //press enter on text area..      $('#txtsearchprodassign').keypress(function(e) {      var key = e.which;      if (key == 13) // enter key code      {        $('input[name = butassignprod]').click();        return false;      }    });    });
<!doctype html>  <html>    <head>    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.min.js"></script>    <meta charset=utf-8 />    <title>js bin</title>  </head>    <body>    <textarea id="txtsearchprodassign"></textarea>    <input type="text" name="butassignprod" placeholder="click here">  </body>    </html>


find demo in jsbin.com


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

.htaccess - Matching full URL in RewriteCond -