Default text which won't be shown in drop-down list

后端 未结 8 1489
情话喂你
情话喂你 2020-11-28 02:17

I have a select which initially shows Select language until the user selects a language. When the user opens the select, I don\'t want it to show a

8条回答
  •  野性不改
    2020-11-28 02:45

    Op1:

    $("#MySelectid option").each(function () {
            if ($(this).html() == "text to find") {
                $(this).attr("selected", "selected");
                return;
            }
    });
    

    Op2:

    $('#MySelectid option')
    .filter(function() { return $.trim( $(this).text() ) == 'text to find'; })​​​​​​​​.attr('selected','selected');​​​​​​​
    

提交回复
热议问题