What is wrong with this jquery each() select options? -
i have below function,
function setdropdownvalue(dropdownid,selectedvalue){ $('#'+dropdownid+' option').each(function(){ if ($(this).val().tolowercase()==selectedvalue.tolowercase()){ //found option looking for, want $(this).val(selectedvalue); } }); }
and passing dropdownid=$('#dp1")
, selectedvalue='bat'
, reason each() function not getting executed.. calling setdropdownvalue($("#dp1"),'bat');
am missing something??
dropdownid
should string, why passing $('#dp1")
jquery object?
you should pass 'dp1'
instead.