在網頁中選了text1 or text2後
<div class="btn-group" role="group" style="padding-left:250px">
<button id="btnGroupDrop1" type="button" class="btn btn-outline-primary dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false" style ="background-color: aliceblue; color: black;">
下拉選單
</button>
<ul class="dropdown-menu" aria-labelledby="btnGroupDrop1">
<li><a class="dropdown-item" href="#">text1</a></li>
<li><a class="dropdown-item" href="#">text2</a></li>
</ul>
</div>
然後放到div內
<div class="col" style="font-size: large;line-height: 3;">
**text1**
</div>
我想用jQuery做,但試不出來
<script>
$(document).ready(function){
$(' ').click(function () {
});
};
</script>
我是想用JQuery,如有別的寫法也可以
希望有高手指點,萬分感激
https://jsfiddle.net/rafu1d4k/
HTML
<select id="selectA">
<option>AAAAA</option>
<option>BBBBB</option>
<option>CCCCC</option>
<option>DDDDD</option>
<option>DDDDD</option>
</select>
<div id="resultDIV"></div>
javascript + JQ 3.4.1
$().ready(function(){
$(document).on("change","#selectA",function(){
$("#resultDIV").html(this.value);
});
})
<ul class="dropdown-menu" aria-labelledby="btnGroupDrop1">
<li><a class="dropdown-item link" href="#">text1</a></li>
<li><a class="dropdown-item link" href="#">text2</a></li>
</ul>
<div id='output'>
</div>
<script>
$('.link').on("click",function (){
var selected = $(this).text();
$('#output').html(selected);
});
</script>