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

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -