Each function in jquery state
1 answer
You have a selection error in select.#ch
, so it must be select > option:selected
either:
$("option:selected", this).each(function() {
str += $(this).text() + " ";
});
However, I would rewrite the code like this:
$("select").change(function () {
var str = $("option:selected", this).map(function() {
return this.innerHTML;
}).get().join(" ");
$("div").text(str);
}).change();
+7
source to share