jQuery :selected Selector

Beginner
5 min read
Updated: Nov 2026
3 examples
Selectors

Definition

:selected (since jQuery 1.0) matches <option> elements that are currently selected in a <select>. Official docs: it does not work for checkboxes or radios — use :checked for those.

Syntax

Start with these common calls. Keep them short and readable.

jQuery
$("option:selected")              // selected options
$("select option:selected")       // official-style scope
$("#city option:selected").text() // visible label
$("#city").val()                  // value attribute (simpler)

// Not for checkboxes / radios → use :checked
// Faster pattern:
$("#city option").filter(":selected")
CallWhat it does
Selector string:selected (best with an option / select prefix)
<select> contextLimits matches to one dropdown
change handlerRefresh labels/values after user input
Return valuejQuery collection of selected <option>s (0+)

Load jQuery before your script (CDN or local file), then wrap DOM work in $(function () { ... }) when needed.

Parameters

ParameterDescription
Step 1Prefer $("select option:selected") or an id-scoped query.
Step 2Bind change on the <select> so results stay current.
Step 3Use .text() for the label, .val() on the select for the value.

Return Value

Return ValueDescription
See examplesCheck the examples below for what this API returns in common cases.

jQuery Examples

Example 1 — Official Demo: option:selected on Change

Collect selected option text whenever the dropdown changes (jQuery API example).

jQuery
$("select")
  .on("change", function () {
    var str = "";
    $("select option:selected").each(function () {
      str += $(this).text() + " ";
    });
    $("#out").text(str);
  })
  .trigger("change");
Try It Yourself

How It Works

  1. Listen. change runs when the user picks a new option.
  2. Query. option:selected finds the currently selected option(s).
  3. Collect. .each() appends each option’s visible text.

Example 2 — :selected Does Not Match Checkboxes

Official rule — use :checked for checkboxes and radios.

jQuery
console.log("option:selected →", $("option:selected").length);
console.log("input:selected →", $("input:selected").length);
console.log("input:checked →", $("input:checked").length);
Try It Yourself

How It Works

  1. Options. option:selected finds the chosen dropdown item.
  2. Wrong tool. input:selected does not match checkboxes.
  3. Right tool. input:checked finds the ticked box.

Example 3 — Label Text vs .val()

Read the visible label with :selected, or the value with .val().

jQuery
function show() {
  $("#out").text(
    "text: " + $("#city option:selected").text() + "\\n" +
    "value: " + $("#city").val()
  );
}
show();
$("#city").on("change", show);
Try It Yourself

How It Works

  1. Text. option:selected + .text() is what the user sees.
  2. Value. $("#city").val() reads the option’s value attribute.
  3. Refresh. Re-run on change so both stay in sync.

Frequently Asked Questions

:selected matches every option element that is currently selected inside a select dropdown. Official jQuery docs: it works for option elements. Available since jQuery 1.0.
No. Official docs state that :selected does not work for checkboxes or radio inputs — use :checked for those control types instead.
:selected targets selected option elements in a select. :checked matches ticked checkboxes, selected radios, and can also match options. Prefer option:selected when you only care about dropdown selections.
Bind change on select, loop $("select option:selected").each() to collect option text, write it to a div, then .trigger("change") for the initial draw — as in the jQuery API docs.
Use $("#mySelect").val() for the value attribute, or $("#mySelect option:selected").text() for the visible label. Both read the current selection after the user changes the dropdown.
Because :selected is a jQuery extension, first select options with a CSS selector then narrow with .filter(":selected") — for example $("#mySelect option").filter(":selected").

Next: :disabled Selector — Disabled Form Controls

Learn how to select disabled form controls with the :disabled selector.

:disabled Selector — Disabled Form Controls tutorial →

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

9 people found this page helpful