嗨,我是jQuery的新手,我正在努力解决这个问题:
从下拉列表中选择值时(
<select>
),则需要使用所选值更改div标记(红色)的内容。请使用jQuery来解决这个测试,请不要在上面的HTML代码中添加任何id/类!
我已经写了一个脚本,但它不起作用,你能帮我吗
var content = $( "div:gt(5)" );
$( "select" ).on( "click", function( event ) {
content.html('6 products');
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="toolbar-wrapper">
<div>
<div>
<label>Product Count</label>
<div class="select-group">
<select>
<option value="4 products" selected="selected">4 products</option>
<option value="6 products">6 products</option>
<option value="8 products">8 products</option>
</select>
</div>
</div>
<div>4 products</div>
</div>
</div>