JQuery examples

From HaFrWiki
Revision as of 10:43, 30 January 2013 by Hjmf (talk | contribs) (Created page with "{{TOCright}} == Combobox == === Selected text === Q: How can I get a dropdownlist/combobox selected text in jQuery? <br>A: There are several possibilities: # The most simple ...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Combobox

Selected text

Q: How can I get a dropdownlist/combobox selected text in jQuery?
A: There are several possibilities:

  1. The most simple solution, but imho very difficult to remember.
    $("#yourdropdownid option:selected").text();
  2. A more optimized way.
    $("#yourdropdownid option").is("selected").text()
  3. One stated this is the fastest.
    $("#yourdropdownid").children("option").is("selected").text()
  4. One stated is() should not be used because it is a boolean whether selected or not.
    $("#yourdropdownid").children("option").filter(":selected").text()

See also

top

Reference

top