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
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
DropDown List Example in JQuery
Mithilesh Kumar
Jun 18
2016
Code
1.8
k
0
0
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
expand
<html>
<head>
<title></title>
<script src=
"Scripts/jquery-2.1.1.js"
type=
"text/javascript"
></script>
<script type=
"text/javascript"
>
$(document)
.ready(function()
{
$(
"#btn1"
)
.click(function()
{
var value = $(
"#ddl1 option:selected"
)
.val();
var txt = $(
"#ddl1 option:selected"
)
.text();
$(
"#ddl1 option[value=Opt2]"
)
.prop(
"disabled"
,
true
);
if
(value !=
"Select"
)
{
alert(
"Select option:"
+
"\n"
+
"value:"
+ value +
"\n"
+
"text:"
+ txt);
}
else
{
alert(
"Please select any one"
);
}
});
});
</script>
</head>
<body>
<form id=
"form1"
runat=
"server"
>
<div>
<b>Select Option:</b>
<asp:DropDownList ID=
"ddl1"
runat=
"server"
>
<asp:ListItem Text=
"Select"
Value=
"Select"
/>
<asp:ListItem Text=
"Option1"
Value=
"Opt1"
/>
<asp:ListItem Text=
"Option2"
Value=
"Opt2"
/>
<asp:ListItem Text=
"Option3"
Value=
"opt3"
/>
</asp:DropDownList>
<input type=
"button"
id=
"btn1"
value=
"Submit"
/>
</div>
</form>
</body>
</html>
JQuery
HTML
DropDown List