In the site I'm trying to dynamically create a JSON array, & lt; Div id = "# selected" & gt; 'S is a dynamic number and I need to take all their values and create a JSON array.
I've come to .push () functionality, but I'm unable to understand it.
& lt ;! - These can be one million, or only one ... Each value is unique though - & gt; & Lt; Div id = "selected" value = "5 | 3" & gt; & Lt; / Div & gt; & Lt; Div id = "selected" value = "3 | 65" & gt; & Lt; / Div & gt; Function json_array_selected () {var JSon = {}; $ ('Div # selected') Every function () let us divide the values given earlier var split = $ (this) .attr ('value'); Split = Split.split ('|'); var type = split [0]; Value = Split [1]; // Now we set our Jason array ... using the value = type method, / should not be repeated repeated JSON.value = type;}); Return JSon; } << Code>
instead of
JSon.Value = type; Try with
JSon [Value] = Type; Or you will always overwrite a key named "Value"
Comments
Post a Comment