Change selected value of drop down list with jQuery
- by Phairoh
I have a drop down list with known values. What I'm trying to do is set the drop down list to a particular value that I know exists using jQuery. Using regular JavaScript, I would do something like:
ddl = document.getElementById("ID of element goes here");
ddl.value = 2; // 2 being the value I want to set it to.
However, I need to do this with jQuery because I'm using a CSS class for my selector (stupid ASP.NET client ids...).
Here are a few things I've tried:
$("._statusDDL").val(2); // doesn't find 2 as a value
$("._statusDDL").children("option").val(2) // also failed.
How can I do it with jQuery?