在我的jquery数据中,我试图以大写形式进行转换,但是它不起作用。
$('#lr_from').val(data.bilty[0].lr_from).toUpperCase();
我的代码:
<div class="form-group row">
<label class="col-md-4">From</label>
<!-- <div class="form-group " class="form-control" > -->
<select class="form-control col-md-8" name="lr_from" id="lr_from" disabled>
<option value="">Select</option>
</select>
<input type="hidden" id="lr_from_id" name="lr_from_id" >
<!-- </div> -->
</div>
$.ajax({
url : "<?php echo base_url();?>enquiry/EnquiryController/getBiltyNo",
type:"POST",
dataType: "json",
data: {
lr_no :lr_no
},
success: function(data){
console.log(data);
$('#lr_from').val(data.bilty[0].lr_from).toUpperCase();
},
});
答案 0 :(得分:1)
尝试使用text()
代替val()
$('#lr_from option').text(function() {
return $(this).text().toUpperCase()
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<select id="lr_from">
<option value="Pune">Pune</option>
</select>