How can I return null instead of 'undefined' from the selected item.
In principle, I have 4 choices at the moment, but only the first one is filled with data at this point, but I want to get a value from all of them when working with them.
<select class="changeValue" id="drpOne"></select> <option id=1>1</option> <option id=2>2</option> <option id=3>3</option> <select class="changeValue" id="drpTwo"></select>
JQuery
$('.changeValue').change(function() { var data = {}; data["Id1"] = $('#drpOne:selected').attr("id"); data["Id2"] = $('#drpTwo:selected').attr("id");
In this case, drpTwo will return 'undefined'. Anyway, to get zero?
source share