HI i'm facing a problem i want to bind the data to dropdown in document.ready function then i want to set a value to the dropdown to highlite the selected value.
Data is binding but im not able to set a value as a selected value.
here is my code...
$(document).ready(function () {
fillDropdown();
$('#sel').val('005');// I want to set here this way
});
function fillDropdown()
{
var url = "sample.json";
$.getJSON(url, function (data) {
$.each(data, function (index, value) {
// APPEND OR INSERT DATA TO SELECT ELEMENT.
$('#sel').append('');
});
//$('#sel').val('005'); /// I dnt want to set here
});
}
Here is the link for example :
https://plnkr.co/edit/ndDtRL?p=preview
Thanks


Suraj KumarRank #353 · 7.1K reputationPosted Jun 13, 2019, 1:31 AM EDT
Gajendra JangidRank #157 · 14.9K reputationPosted Jun 12, 2019, 9:09 AM EDT
Suraj KumarRank #353 · 7.1K reputationPosted Jun 12, 2019, 9:16 AM EDT
Anilananda ChakraborttyRank #3,903 · 381 reputationPosted Jun 12, 2019, 6:42 PM EDT
Jignesh KumarRank #91 · 22.9K reputationPosted Jun 12, 2019, 10:13 PM EDT
Anilananda ChakraborttyRank #3,903 · 381 reputationPosted Jun 12, 2019, 10:31 PM EDT