jQuery Values

联合创作 · 2023-10-02

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.

浏览 1
点赞
评论
收藏
分享

手机扫一扫分享

编辑
举报
评论
图片
表情
推荐
点赞
评论
收藏
分享

手机扫一扫分享

编辑
举报