jquery - How to make the select box value back to the default value -
here want make select box value default value.
$(".reportingto").change(function() { var reportingtovalue = $(this).val(); var reportingtoid=$(this).attr('id'); $('select[id^="reportingto"]').each(function() { if(reportingtoid!==$(this).attr('id')&& reportingtovalue===$(this).val()){ alert("duplicate found"); $(reportingtoid).val( $(reportingtoid).prop('defaultselected') ); } });
if default value first/top one, solution work you.
// replace $(reportingtoid).val( $(reportingtoid).prop('defaultselected') ); // $('#'+reportingtoid).prop('selectedindex',0);
Comments
Post a Comment