How to use jQuery .trigger() to trigger focus on HTML <button>

1 Answer

0 votes
<!doctype html>
<html>
<head>
  <script src="js/jquery/1.11.3/jquery.min.js"></script>
</head>
<body>

<button id="id-button">click</button>
 
<input id="id-input-1" type="text" value="some text 1">
<input id="id-input-2" type="text" value="some text 2">
<script>
$( "#id-button" ).click(function() {
  $( "#id-input-2" ).trigger( "focus" );
});
</script>
</body>
</html>

 



answered Aug 23, 2016 by avibootz
...