我对下面的代码有疑问。我想做的是在提交表单之前根据在两个下拉选项中选择的内容预览图像。
$(document).ready(function() {
$('#form-image1').on('onchange', function() var option1 = document.getElementById("option1");
var option2 = document.getElementById("option2");
var option1selection = option1.options[option1.selectedIndex].value;
var option2selection = option2.options[option2.selectedIndex].value;
if (colourselection == "Blush " && patternselection == “Horizontal Stripes”) {
$('#image1').attr('src', ‘https: //i.imgur.com/FHWSAJt.png’);
)
};
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<img id="image1" src="https://www.w3schools.com/images/lamp.jpg" alt="Lamp" width="32" height="32" />
<select class="form-image1" id="option1" name="option1">
<option value="A">A</option>
<option value="B">B</option>
<option value="C">C</option>
</select>
<select class="form-image1" id="option2" name="option2">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
偶然的你
侃侃无极
相关分类