jquery - Selectbox OnChange copy this text to div -
how can change div text selectbox option selected text...
i have selectbox more 100 values
scenario: select option selectbox, same option value(text) has replaced relevant div text has ccy
class <div class="ccy">blablabla</div>
class...
eg: have selectbox eur, usd, jpy, inr etc... if select eur selectbox, relevant divs has class ccy <div class='ccy'>currency 1</div><div class='ccy'>currency 2</div>
should changed <div class='ccy'>eur</div><div class='ccy'>eur</div>
, on...
fiddle
html
<select id="currencty-selectbox"> <option value="1">eur</option> <option value="2">usd</option> <option value="3">jpy</option> <option value="4">cad</option> <option value="5">mxn</option> <option value="6">czk</option> </select> <div class='ccy'>currency 1</div> <div class='ccy'>currency 2</div>
jquery
$('#currencty-selectbox').on('change', function() { alert( $(this).find(":selected").text() ); });
$('#currencty-selectbox').on('change', function () { $('.ccy').text($(this).find(":selected").text()); // ^^^^^^ }).trigger('change');
Comments
Post a Comment