control-freak-ide/Control-Freak-Documentation/jQuery/docs/entries/selected-selector.json
plastic-hub-dev-node-saturn 538369cff7 latest
2021-05-12 18:35:18 +02:00

1 line
1.3 KiB
JSON

{"name":"selected","type":"selector","title":":selected Selector","deprecated":null,"removed":null,"desc":"Selects all elements that are selected.","categories":["selectors/form-selectors","selectors/jquery-selector-extensions","version/1.0"],"entries":[{"return":"","signatures":{"added":"1.0"},"examples":{"desc":"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.","code":"\n$( \"select\" )\n .change(function() {\n var str = \"\";\n $( \"select option:selected\" ).each(function() {\n str += $( this ).text() + \" \";\n });\n $( \"div\" ).text( str );\n })\n .trigger( \"change\" );\n","css":"\n div {\n color: red;\n }\n","html":"\n<select name=\"garden\" multiple=\"multiple\">\n <option>Flowers</option>\n <option selected=\"selected\">Shrubs</option>\n <option>Trees</option>\n <option selected=\"selected\">Bushes</option>\n <option>Grass</option>\n <option>Dirt</option>\n</select>\n<div></div>\n"},"longdesc":"\n <p>The <code>:selected</code> selector works for <code>&lt;option&gt;</code> elements. It does not work for checkboxes or radio inputs; use <code>:checked</code> for them.</p>\n "}],"slug":"selected-selector"}