How to set the 'selected option' of a select dropdown list with jquery

后端 未结 6 1507
南笙
南笙 2021-01-31 09:07

I have the following jquery function:

$.post(\'GetSalesRepfromCustomer\', {
    data: selectedObj.value
}, function (result) {
    alert(result[0]);
    $(\'sele         


        
6条回答
  •  梦谈多话
    2021-01-31 09:32

    Set the value it will set it as selected option for dropdown:

    $("#salesrep").val("Bruce Jones");
    

    Here is working Demo

    If it still not working:

    1. Please check JavaScript errors on console.
    2. Make sure you included jquery files
    3. your network is not blocking jquery file if using externally.
    4. Check your view source some time exact copy of element stop jquery to work correctly

提交回复
热议问题