IamCalvinBrown.com a Blog Site

Code Examples, Consulting Advice and lots of other cool things

Selecting an item by name in a dropdown in JQuery



<select id="clients">

 <option value="1" >John</option>

  <option value="2">Calvin</option>

  <option value="3">Adjo</option>

</select>

// the list above is named clients, so the code below will select the item by name
$("#clients option:contains('Calvin')").attr('selected', true);

Loading