How can a JavaScript array be stored in an HTML custom data attribute?
I've tried every variation of JSON stringification and escaping characters.
What is the precise method to store the array and retrieve it again?
I build the array with [ $("#firstSelectedElement").val(), $("#secondSelectedElement").val() ]
. I retrieve id="storageElement" data-storeIt="stuff"
with $("#storageElement").data('storeit')
.
I can never seem to retrieve the data as a true array, only an array of characters.
data-stuff="['some', 'string', 'here']"
(notice the'
), any guidance would be appreciated. – Marashio