实现这一目标的最简单、最容易的方法 $('#button').on('click', function () { $('.form-group input[type="text"]').attr('autofocus', 'true'); });