I have a table with class "tbl1", This table contains drop down menu column with class empID
Now I want to check for each row to prevent selecting the same option more than one time and alert user that this option already selected before if he selected.
here what i tried but it is not working:
$(document).ready(function(){
perventDuplicate ();
$('.tbl1').on('change', '.EmpID select', perventDuplicate);
function perventDuplicate() {
$('.tbl1 tbody tr').each(function () {
$(this).find('.empID select').each(function () {
if( $(this).find('option[value='+$(this).val()+']:selected').length>1){
alert('option is already selected');
$(this).val($(this).find("option:first").val());
}
});
});
};});