Skip to content

A less bug-prone way to find elements by their name attribute. When the name is dynamic bugs are easily introduced while typing '[name="' + name + '"]'. Just use $.findByName(name) instead.

License

punkave/jquery-find-by-name

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

jquery-find-by-name

jquery-find-by-name provides a less bug-prone way to find elements by their name attribute. In particular, when the name attribute is stored in a variable it is very bug-prone to write a selector for it by hand every time.

How to Use

$('.my-element').findByName('age');

And especially:

$.each(fields, function(i, field) {
  $('.my-element').findByName(name);
});

Requirements

You need jQuery, of course. jquery-find-by-name is actively supported with jQuery 1.9 and 2.0 but should work fine with older versions.

About P'unk Avenue and Apostrophe

jquery-find-by-name was created at P'unk Avenue for use in Apostrophe, an open-source content management system built on node.js. If you like jquery-find-by-name you should definitely check out apostrophenow.org. Also be sure to visit us on github.

Support

Feel free to open issues on github.

About

A less bug-prone way to find elements by their name attribute. When the name is dynamic bugs are easily introduced while typing '[name="' + name + '"]'. Just use $.findByName(name) instead.

Resources

License

Stars

Watchers

Forks

Packages

No packages published