jQuery dropdown selected=selected in Safari does not work

I found the answer!

You can use .prop('selected', true) in stead off attr('selected','selected');


The following function works in current Safari, Safari Mobile, Chrome, Edge, and Firefox as of this writing.

This handles the issue where the .prop calls MUST be done before the .attr calls or the entire thing is ignored, and the redraw issue in firefox.

    function updateSelect(selectname, value){
        $('select[name="'+selectname+'"] option').prop('selected',false);
        $('select[name="'+selectname+'"] option').removeAttr('selected');
        $('select[name="'+selectname+'"] option[value="'+value+'"]').prop('selected',true);
        $('select[name="'+selectname+'"] option[value="'+value+'"]').attr('selected','selected');
        $('select[name="'+selectname+'"]').val(value).change();
    }