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
just make sure the value in the options tags matches the value in the val method.
Here is a function made to quickly set the selected option:
Call this function with argument element id and selected value; like this:
It is useful when there are lot of select options to be set.
Using the highlighted/checked answer above worked for me... here's a little insight. I cheated a little on getting the URL, but basically I'm defining the URL in the Javascript, and then setting it via the jquery answer from above:
In case when you load all
<options ....></options>
by Ajax callFollow these step to do this.
1). Create a separate method for set value of drop-down
For Ex:
2). Call this method when ajax call success all html append task complete
For Ex:
Set
drop-down
selected
value and update changesHere we first set value from
Model
and than updated it on chosenTry:
Or to get the text of the option, use text():
More Info: