set option “selected” attribute from dynamic created option

后端 未结 17 1737
时光说笑
时光说笑 2020-11-30 20:01

I have a dynamically created select option using a javascript function. the select object is


<         


        
17条回答
  •  天涯浪人
    2020-11-30 20:55

    This should work.

    $("#country [value='ID']").attr("selected","selected");
    

    If you have function calls bound to the element just follow it with something like

    $("#country").change();
    

提交回复
热议问题