问题
This is a simple question.
How do I change the "badge's price from $10 to $20" with select onChange?
<span class="badge badge-primary">$10</span>
<select>
<option>$10 Item</option>
<option>$20 Item</option>
</select>
Please provide the HTML and jQuery.
P.S. I don't want to use an image for the badge's price. Thanks.
回答1:
HTML:
<span id="mybadge" class="badge badge-primary">$10</span>
<select id="myselect">
<option value="$10">$10 Item</option>
<option value="$20">$20 Item</option>
</select>
Javascript:
$('#myselect').change(function(){
$('#mybadge').text($(this).val());
});
Working jsFiddle ->> http://jsfiddle.net/sUBWd/5/
来源:https://stackoverflow.com/questions/15137744/select-onchange