jQuery Values
Makes it trivial to get/set values from any descendants of a DOM element(s), not just input and select elements. Simply add "name" attribute(s) (as you do for form elements) to the elements whose values you wish to retrieve or set and call values() on a parent selection to retrieve those keys/values in a handy little hash object.
To get all values:
var values = $('.parent').values();
To set values:$('.parent').values({ foo: 'bar', answer: 42 });
To get one value:var foo = $('.parent').values('foo');
To set one value:$('.parent').values('foo', 'bar');
For more details on all available functions and configuration options, see the comments in the source.
评论