TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Anilananda Chakrabortty
NA
425
78k
Bind a dropdown list and set a default value in jQuery
Jun 12 2019 12:41 PM
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('<option value="' + value.ID + '">' + value.Name + '</option>');
});
//$('#sel').val('005'); /// I dnt want to set here
});
}
Here is the link for example :
https://plnkr.co/edit/ndDtRL?p=preview
Thanks
Reply
Answers (
6
)
how to drag and drop form using jquery??
how to add and remove column row in jquery??