As the question says, how do I set the value of a DropDownList control using jQuery?
相关问题
- How to fix IE ClearType + jQuery opacity problem i
- jQuery add and remove delay
- Include empty value fields in jQuery .serialize()
- Disable Browser onUnload on certain links?
- how to get selected text from iframe with javascri
If you working with index you can set the selected index directly with .attr():This will set it to the first value in the droplist.
Edit: The way I did it above used to work. But it seems like it doesn't any longer.
But as Han so pleasantly points out in the comments, the correct way to do it is:
If your dropdown is Asp.Net drop down then below code will work fine,
But if your DropDown is HTML drop down then this code will work.
Best answer for the question:
e.g:
or
There are many ways to do it. here are some of them:
OR
In this article there are different ways to Select drop down value using Jquery.
//Html Format of the dropdown list.
// If you want to change the selected Item to test2 using javascript. Try this one. // set the next option u want to select
As suggested by @Nick Berardi, if your changed value is not reflected on the UI front end, try: