is it possible to add a case statement to that? The thing is that now it takes the value from the droplist and writes it to #shop_price. I want to add a statement that when it receives for example “door”, instead of writing that, it would write something else (eg. price:).
$("select.category").change(function () { var str = ""; $("select.category option:selected").each(function () { str += $(this).text(); }); $("#shop_price").text(str); }) .change();
If we are talking about a single-select dropdown, you can do it much easier using
val:If there is going to be a lot of special cases (otherwise why use
switchinstead ofif?), you can make a map: