Jquery 如何基于所选选项显示图像

Jquery 如何基于所选选项显示图像,jquery,drop-down-menu,Jquery,Drop Down Menu,我正在尝试根据用户选择来显示图像 这是contentType表 id | Type | Image | 选项从while语句中检索,如下所示: <select style="cursor:pointer;" id="contentMarketingTypeSelector" name="contentMarketingType" class="form-control contentMarketingType"> <option>Please select con

我正在尝试根据用户选择来显示图像

这是
contentType

id | Type | Image |
选项从while语句中检索,如下所示:

   <select style="cursor:pointer;" id="contentMarketingTypeSelector" name="contentMarketingType" class="form-control contentMarketingType">
<option>Please select content type</option>';
        while($ctype = $resultstmt_uppt->fetch_assoc()){
        $socialmediaform .= '<option id="'.$ctype['Type'].'">'.$ctype['Type'].'</option>';
          }
</select>
<div class='contentImageType'></div>

我有点迷路了…你能帮我吗?感谢

一个快速且非常简单的jQuery解决方案。将值设置为
,将id设置为

Html

您可以从插件获得帮助

 $(function() {
                $('#contentMarketingTypeSelector').change(function(){


                });
            });
 <div class='contentImageType'>
<img style="max-width:100% !important;" class="responsive" src="" name="image-swap">
</div>
  <select style="cursor:pointer;" id="contentMarketingTypeSelector" name="contentMarketingType" class="form-control contentMarketingType">
<option>Please select content type</option>';
        while($ctype = $resultstmt_uppt->fetch_assoc()){
        $socialmediaform .= '<option value="'.$ctype['Image'].'">'.$ctype['Type'].'</option>';
          }
</select>
$(function() {
                $('#contentMarketingTypeSelector').change(function(){

                  $("img[name=image-swap]").attr("src",$(this).val());

                });
            });