Selecting Element by Name in jQuery

Published on October 13, 2015 by

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?

Author avatar
Bo Andersen

About the Author

I am a back-end web developer with a passion for open source technologies. I have been a PHP developer for many years, and also have experience with Java and Spring Framework. I currently work full time as a lead developer. Apart from that, I also spend time on making online courses, so be sure to check those out!

Leave a Reply

Your e-mail address will not be published.