over 5 years ago
While working in Asp.Net Application I got stuck in a following issue.
This is the code I am using:
<select class="form-control" id="new-account-prefix" name="newaccountprefix">
<option disabled selected></option>
This is my DropDown, I wan't to get the selected text in my .js file using jquery.
If the user selects 'Mr.' I wan't the selected value (i.e 'Mr.') using jquery.
Anybody have some idea, how to acheive this.... Thanks in Advance..!
You can get the selected text using following syntax.
Often people confuse between text and val. So the difference is:
.text() gives you the selected text what you are seeing on the dropdown.
.val() gives you the value part in of the "option" element.
If you write
you will get Mr.,Ms or whatever you select and see in the dropdown
But if you write
you will get "mr","ms" etc as your result
Starting with Chrome version 45, NPAPI is no longer supported for Google Chrome. For more information, see Chrome and NPAPI (blog.chromium.org).
Firefox and Microsoft Internet Explorer are recommended browsers for websites using java applets.
Chrome Version Support
Are you sure, you want to delete this comment?
Terms of Service
| © copyright 2021 FindNerd.com. All rights reserved.
Sign up using