I am trying to add more than one attr() value when using append in a dropdown in jQuery.
This is working fine:
$('#twostages').append($('<option/>').attr("value", option.stage).text(option.stage));
And I can access the value using:
document.getElementById("twostages").value
However, when I try this code:
$('#twostages').append($('<option/>').attr({ "value": option.stage, "matone": option.matone }).text(option.stage));
I am not able to retrieve the value
or matone
using the document.getElementById("twostages").value
or document.getElementById("twostages").matone
I got the idea of the above code from this topic: jQuery: Adding two attributes via the .attr(); method
Any help would be greatly appreciated.
Thanks.