:selected Selector

selected selector

version added: 1.0jQuery(':selected')

描述: 选择所有被选中的元素。

:selected 选择器为<option>元素工作。它不适用复选框和单选框,复选框和单选框请使用:checked


Attaches a change event to the select that gets the text for each selected option and writes them in the div. It then triggers the event for the initial text draw.

<!DOCTYPE html>
  div { color:red; }
  <script src="http://code.jquery.com/jquery-latest.min.js"></script>
  <select name="garden" multiple="multiple">

    <option selected="selected">Shrubs</option>
    <option selected="selected">Bushes</option>


    $("select").change(function () {
          var str = "";
          $("select option:selected").each(function () {
                str += $(this).text() + " ";



jQuery 1.6 API 中文版Clove整理、修订