我有下面的代碼,它不工作。我想將選定的文本放到我選擇的位置div中。有任何想法嗎?謝謝!把文字分隔與下拉選項
<select name='available_locations' class='select-location'>
<option value='Germany'>Germany</option>
<option value='Venice'>Venice</option>
<option value='Spain'>Spain</option>
</select>
<div id='selected-locations'>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
<script type='text/javascript'>
$(document).ready(function() {
$('.select-location').change(function(){
var location = $(this).attr('value');
alert(location);
//new_text = $('#selected-locations').val() + location;
$('div.selected-locations').text(location);
});
});
</script>
噢,那是行得通!我的錯。謝謝! – Emkey