Trying to extract an element attribute value that is part of an object
I have an input field coded as the following:
- <input type="radio" name="03794" class=" js-sourcing-option" data-sourcingoption="{"hasBackOrder":true,"isPartial":false,"unsourcedQty":0,"warehouseSequences":[1],"shipments":{"2017-10-12T17:00:00":{"warehouseNumber":101,"deliverByTime":"2017-10-12T17:00:00","numShipments":0,"warehouseQty":0,"backorderQty":1,"qtyByWarehouseInStock":{},"qtyByWarehouseBackorder":{"101":1}}},"sourcedQty":1,"shouldDisplay":true}">
Using jQuery, I cannot figure out how to get the value of "
deliverByTime" (which should equal "
2017-10-12T17:00:00") buried deep within the "
data-sourcingoption" attribute of this field.
The following will successfully output the "name" attribute:
(the "[0]" is there below because there are more of these on the page)
- $('input.js-sourcing-option')[0]["name"]
- // Output: 03794
But if I do a similar thing for "data-sourcingoption" to try and play with the results and extract what I need, I get this:
- $('input.js-sourcing-option')[0]["data-sourcingoption"]
- // Output: undefined
Any help would be greatly appreciated...thank you!