Want to become a Vibe Coder? Join Vibe Coding Training here
x
C# Corner
Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
Bind Values To Dropdown List Using KnockoutJS
WhatsApp
Rupesh Kahane
Jul 22
2016
2.2
k
0
0
@{
Layout
=
null
;
}
<!DOCTYPE html
>
<
html
>
<
head
>
<
meta
name
=
"viewport"
content
=
"width=device-width"
/>
<
title
>
DropDown
</
title
>
<
script
src
=
"~/Scripts/jquery-2.2.0.js"
>
</
script
>
<
script
src
=
"~/Scripts/knockout-3.4.0.js"
>
</
script
>
</
head
>
<
body
>
<
div
>
<
label
>
Color :
</
label
>
<
select
data-bind
=
"value: selectedColor"
>
<
option
>
Red
</
option
>
<
option
>
Green
</
option
>
<
option
>
Blue
</
option
>
<
option
>
White
</
option
>
<
option
>
Orange
</
option
>
<
option
>
Black
</
option
>
</
select
>
</
div
>
</
body
>
</
html
>
<
script
>
var
viewModel
=
ko
.observable({
selectedColor: "Blue"
});
ko.bind($("select"), viewModel);
</
script
>
Bind Values
Dropdown List
KnockoutJS