1 回答
TA贡献1866条经验 获得超5个赞
发生这种情况是因为 textarea 类相同。
你快到了。使用thiswithnext在文本区域上获得所需的结果。
//Insert value form dropdown in textarea
$(document).ready(function(){
$(".js-example-basic").change(function () {
$(this).next(".textArea").val(this.value);
}).change();
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div>
<select name="selectProgram[]" class="js-example-basic">
<option value="">Choose tour</option>
<option value="Tour1">Tour 1</option>
<option value="Tour2">Tour 2</option>
<option value="Tour3">Tour 3</option>
</select>
<textarea name="tourText[]" class="form-control textArea" placeholder="Tour description"></textarea>
</div>
<div>
<select name="selectProgram[]" class="js-example-basic">
<option value="">Choose tour</option>
<option value="Tour1">Tour 1</option>
<option value="Tour2">Tour 2</option>
<option value="Tour3">Tour 3</option>
</select>
<textarea name="tourText[]" class="form-control textArea" placeholder="Tour description"></textarea>
</div>
添加回答
举报