I have a table of form elements where each row represents a record and column represents a field. I need to select all form elements in a given column.
Form elements in the same column have the same name format. For example, form elements that represent a location would have a name in the format record*.location, where * is an index.
Is it possible to select them with a single jQuery selection? If so, how does it compare to doing document.getElementById() on each one of them in a loop, performance wise?
Use jQuery’s custom selector creation, $.expr. I have an example for you at http://jsfiddle.net/ygSAy/
You’ll want to limit use of it to specific contexts unless you really work to make the filter function super efficient.
Edit: a commented and slightly better performant version: http://jsfiddle.net/ygSAy/2/