I’m using a third-party jQuery plugin that gets the values, settings and preferences of a <select> element and replaces it with a custom widget.
How can I find out the default value of a <select> element?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Use
To get the currently (or default) selected item. To get it’s value, use
Or
If you want to be shorter/faster.
To get the select’s original value, you need to store it in the element’s data using the
.data()function, as this JSFiddle shows.When you want to retrieve the value, simply call
.data("originalValue")on the select element (second.each()of the JSFiddle.You need to run the first
.each()call in the above code when your page loads to store the select box’s original value. Do note thatoriginalValuecan be any identifier you like.