JSON配列を動的に作成しようとしています。サイトには動的な数の <div id="#selected"> があり、それらの値をすべて取得して JSON 配列を作成する必要があります。
.push() 機能に遭遇しましたが、理解できませんでした。
<!-- there could be a million of these, or only one... each value is unique though -->
<div id="selected" value="5|3"></div>
<div id="selected" value="3|65"></div>
function json_array_selected() {
var JSon = {};
$('div#selected').each(function() {
// let's first split the given values
var Split = $(this).attr('value');
Split = Split.split('|');
var Type = Split[0];
Value = Split[1];
// now let's set up our Json array... using the value = type way, there should never be
// any repeating
JSon.Value = Type;
});
return JSon;
}