Javascript 使用jQuery开关在输入更改时更改图像

Javascript 使用jQuery开关在输入更改时更改图像,javascript,jquery,fonts,switch-statement,Javascript,Jquery,Fonts,Switch Statement,我正在创建一个字体示例,该示例将在选项选择时更改。然而,它似乎不起作用。我在前面的一个问题中使用了类似的格式,但不知何故,这次似乎没有响应。。谢谢 <div class="form-input"> <label class="label" for="font-choice">Not sure which font? Choose from our top 12: </label> <select class="form-select" id="engra

我正在创建一个字体示例,该示例将在选项选择时更改。然而,它似乎不起作用。我在前面的一个问题中使用了类似的格式,但不知何故,这次似乎没有响应。。谢谢

<div class="form-input">
<label class="label" for="font-choice">Not sure which font? Choose from our top 12: </label>
<select class="form-select" id="engraving-type">
<option style="font-family: Arial" value="Arial">&nbsp; &nbsp; &nbsp; Arial</option>
<option style="font-family: Baskerville" value="Baskerville"> &nbsp; &nbsp; &nbsp; Baskerville</option>
<option style="font-family: Baroness Bold" value="Baroness Bold"> &nbsp; &nbsp; &nbsp; Baroness Bold</option>
<option style="font-family: Cantania" value="Cantania"> &nbsp; &nbsp; &nbsp; Cantania</option>
<option style="font-family: Century Gothic" value="Century Gothic"> &nbsp; &nbsp; &nbsp; Century Gothic</option>
<option style="font-family: Chinese" value="Chinese"> &nbsp; &nbsp; &nbsp; Chinese</option>
<option style="font-family: Edwardian Script" value="Edwardian Script"> &nbsp; &nbsp; &nbsp; Edwardian Script</option>
<option style="font-family: Dagobent" value="Dagobent"> &nbsp; &nbsp; &nbsp; Dagobent</option>
<option style="font-family: Goudy" value="Goudy"> &nbsp; &nbsp; &nbsp; Goudy</option>
<option style="font-family: Palatino" value="Palatino"> &nbsp; &nbsp; &nbsp; Palatino</option>
<option style="font-family: Baroness Bold" value="Baroness Bold"> &nbsp; &nbsp; &nbsp; Baroness Bold</option>
<option style="font-family: Times New Roman" value="Times New Roman"> &nbsp; &nbsp; &nbsp; Times New Roman</option>
</select>
</div>


<div class="form-input">
<label class="label" for="form-table">Font example:</label><span id="text-example"><img id="font-image" src="/images/fonts/Font-Baskerville.jpg" /></span>
</div>
<script>
  $( document ).ready(function() {
  $("#engraving-type").change(function(){
    switch (this.value) {
    case 'Arial': 
        var image = 'Font-Arial.jpg'; 
        break;
    case 'Baskerville': 
       var image = '/#'; 
        break;
    default:
       var image = 'Font-Baskerville.jpg'; 
        break;
    }
    $( "#font-image" ).attr("src", "/images/fonts/" + image);
    });
});
</script>
更换这条线

switch (this.value)


两种情况都是正确的。一种是纯javascript,另一种是jqueryif alertimage。您得到了什么?请试着告诉我它对我有用-请让你添加jquery库?嗯,它不会发出警报。案件陈述可能有问题吗?真奇怪。添加了jQuery库。这是不可能的。
switch ($(this).val())