我试图从jQuery中的选择对象中获取某些值。
现在,我需要在console.log中发布我需要的值 - 但只有整个对象。问题是有多个对象,我需要输出id - 显示在这里:
从控制台:
[s, s]
0: s
_changing: false
_events: Object
_listenId: "l89"
_pending: false
_previousAttributes: Object
attributes: Object
changed: Object
cid: "c46"
collection: s
id: 72
__proto__: n
1: s
_changing: false
_events: Object
_listenId: "l91"
_pending: false
_previousAttributes: Object
attributes: Object
changed: Object
cid: "c47"
collection: s
id: 71
__proto__: n
length: 2
__proto__: Array[0]
我需要的是将id 72和71推入一个可用于设置输入值的数组。
现在我有这个:
.on('select', function(e){
var uploaded_image = image.state().get('selection').each(function(){
//console.log('running');
});
console.log(uploaded_image);
var image_id = uploaded_image['id'];
$('#image_id').val(image_id);
$('#image_url').val(image_url);
});