Home
Categories
HTML Select
CSS Class
General
CheckBox
HTML Textarea
DropDown
jQuery UI
DatePicker
Facebook
HTML Form
HTML DIV
ASP.Net
JSON
Radio
Regular Expressions
HTML Multiselect ListBox
HTML TextBox
RadioButtonList
CheckBoxList
HTML Anchor
Master Pages
HTML5
Bootstrap
Image
FileUpload
HTML Span
ListBox
jQuery
Table
Button
Password TextBox
Sponsored
XML
Forums
Contact
Search
Search
Home
Categories
Forums
Contact
Search
Get all options of HTML SELECT and their attributes using jQuery
18 Jun 2011
Mudassar Khan
0
Comments
4120 Views
HTML Select
Follow @jQueryFaqs
Follow @jQueryFaqs
Here Mudassar Ahmed Khan has explained how to get all options of HTML SELECT and their attributes using jQuery
Follow @jQueryFaqs
Follow @jQueryFaqs
The below code snippet explains how to get all options of HTML SELECT and their attributes using jQuery
<
select
id
="mySelect">
<
option
value
="1">
Yes
</
option
>
<
option
value
="2">
No
</
option
>
</
select
>
<
input
type
="button"
id
="demo"
value
=
"Demo"
/>
<
script
type
="text/javascript">
$(
"#demo"
).live(
"click"
,
function
() {
//Get all options and loop using jQuery
$(
"#mySelect option"
).each(
function
() {
alert(
"Index: "
+ $(
this
).index() +
",Value: "
+ $(
this
).val() +
",Text: "
+ $(
this
).html() +
",IsSelected: "
+ $(
this
).is(
":selected"
));
});
});
</
script
>
Comments
No comments have been added to this article.
Add Comments
Thank you for the feedback. The comment is now awaiting moderation. You will be notified via email when the author replies to your comment.
Please select a comment to reply
You can add your comment about this article using the form below. Make sure you provide a valid email address
else you won't be notified when the author replies to your comment
Please note that all comments are moderated and will be deleted if they are
Not relavant to the article
Spam
Advertising campaigns or links to other sites
Abusive content.
Please do not post code, scripts or snippets.
Follow @jQueryFaqs
Follow @jQueryFaqs
Name
Required
Email
Required
Invalid Email Address
Comment
Required
Security code:
Required
Invalid security code.
Add Comment
Message from Author
Message from Author
Subscribe
Follow @jQueryFaqs
Follow @jQueryFaqs
Error Details
Disclaimer
This site makes use of Cookies. Please refer
Privacy Policy
for more details.