我不知道如何在 Jquery 中编写代码:
<textarea>I am living in varA varB VarC</textarea>
<select name="city" id="city">
<option value="1">City1</option>
<option value="2">City2</option>
</select>
当客户选择选择城市时,varC 将显示 City1 或 City2,但当他们重新选择时,varC 也会相应更改。所选地区和病房的 varA 和 varB
<select name="district" id="district">
<option value="1">District1</option>
<option value="2">District</option>
</select>
<select name="ward" id="ward">
<option value="1">Ward1</option>
<option value="2">Ward</option>
</select>
感谢您对我的帮助!
你可以做类似的事情。正如人们所说,Stackoverflow 社区并不是为你编写代码。雇用一名开发人员...
$('select').on('change',function(){
let district = $('#district').val()
let ward = $('#ward').val()
let city = $('#city').val()
$('textarea').val('I am living in '+district+' '+ward+' '+city)
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<select name="district" id="district">
<option value="District1">District1</option>
<option value="District">District</option>
</select>
<select name="ward" id="ward">
<option value="Ward1">Ward1</option>
<option value="Ward">Ward</option>
</select>
<select name="city" id="city">
<option value="City1">City1</option>
<option value="City2">City2</option>
</select>
<textarea>I am living in varA varB VarC</textarea>