我有一小段JavaScript,它根據(jù)下拉列表更改圖像。它當(dāng)前工作并根據(jù)需要更改圖像。不幸的是,如果圖像不存在,它會顯示丟失的圖像圖標(biāo),我寧愿它保留默認(rèn)圖像。我的腳本是 -<script>$(function() { $("#input_1").change(function(){ var selectedImage = $(this).find(':selected').val(); val = $("#input_1 option:selected").text(); $("a.lb:first").html( "<img src=images/11_" + selectedImage + ".jpg>"); $('a.lb:first img').addClass( "img-fluid" ); });});</script>我的網(wǎng)頁是 -<img src="images/11_1.jpg" alt="Objective Marker Bases" title="Objective Marker Bases" class="img-fluid"><select name="id[1]" required="required" aria-required="true" id="input_1" class="form-control"><option value="" selected="selected">--- Please Select ---</option><option value="1">White</option><option value="2">Yellow (+£1.00)</option><option value="4">Blue</option></select>
腳本更改下拉列表中的圖像 - 缺少圖像
收到一只叮咚
2022-09-23 14:58:21