私のjQueryのコードは次のとおりです。私はエラーを取得する声明this.prop("selected", true);
を使用して上this.propは関数ではありませんか?
$.each($("#price_based_on").children('option'), function(index, val) {
if(this.value.toUpperCase()==currentRow.price_based_on.toUpperCase())
{
console.log("Match");
this.prop("selected", true);
}
});
:このうち、
$('#edit').click(function(){
var data = $("#list :input").serialize();
$.post($("#list").attr('action'), data, function(json)
{
currentRow = json.rowArr[0];
$("#id").val(currentRow.id);
$("#id_disp").val(currentRow.id);
$("#shop").val(currentRow.shop);
$("#category").val(currentRow.category);
$("#item").val(currentRow.item);
$("#qnty").val(currentRow.qnty);
$("#unit").val(currentRow.unit);
$.each($("#price_based_on").children('option'), function(index, val) {
if(this.value.toUpperCase()==currentRow.price_based_on.toUpperCase())
{
console.log("Match");
this.prop("selected", true);
}
});
$("#mrp").val(currentRow.mrp);
$("#sellers_price").val(currentRow.sellers_price);
$("#last_updated_on").val(currentRow.last_updated_on);
},"json");
});
、興味のある唯一のものは線です
Uncaught TypeError: this.prop is not a function
.prop()が明らかに存在する関数である場合、なぜこれが起こりますか?どうすれば修正できますか?
'this'をjQueryオブジェクトにする必要があります。' $(this).prop'は動作するはずです – TryingToImprove