Selecting elements based on their name attribute in jQuery is as easy as it should be. We can accomplish this by simply using the attribute selector as follows.
For example, to select an input with the name username, use the following selector.
var matches = $('input[name="username"]');
Woah, that was easy, wasn’t it?