Selecting Element by Name in jQuery

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?

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *