jquery - Setting Dropdownlist Value after dynamically generating options -


I have this code to populate the drop down list

  $ ("# btnEditInfo ") .click (function (e) {e.preventDefault (); $ (" # ddlLocations ") (blank) .andend ($ (" & lt; option & gt; & lt; / option & gt; ") . Val ( "[-]"). Html ( "[- select Area -]")) ;; populated place DDL (); $ ( "# ddlLocations"). Val (4);  < / pre> 

PopulateLocationDDL

  function populateLocationDDL () {$. Ajax ({type: "POST", url: "adminc.aspx / getLocationList", data: "{}", ContentType: "App / Jason; alphabet = UTF-8", datatype: "Jason", success: function (Ellen) {$ Kiisi (Ellen D function (val 1, text) {$ ( "# Deedielokeshn"). Aepend ($ ( "(& lt; base & gt; & lt; / option & gt;"). Val (text. location ID). HTML (text.Name));}); $ ( "# ddlLocations"). attachment ($ ( "& lt; & gt; & lt; / options opti & gt;"). Val (arten .length + 1) .html ("other ..."));}};}  

Now I want to be able to choose the fourth option in the drop down list. This is not working

Any help would be highly appreciated .. Here is the jsfiddle.net/yYZ48
thanks

Try it out:

$ (" # ddlLocations Options: AC (3) "). Ether ('selected', 'selected');

Or this:

  $ ("# ddlLocations"). Val ($ ("# ddl Location Option: eq (3)"). Val ());  

Comments