我有一個名爲「cost」的變量(字符串)。如果我試圖將其分配給如何將一個JQuery變量值分配給Laravel Blade輸入
<p class="cost"> </p>
它工作正常。但是,當我嘗試將其分配給Blade生成的「只讀」輸入時,我得到沒有任何內容。我在輸入字段中沒有輸出「成本」值。我嘗試瞭解BLade輸入,也嘗試了原始JS。
$(".quantity").on('change', function(){
var quantity = parseInt($(this).val());
var num = (price * quantity);
var cost = num.toString();
$('.cost').html(cost); // This will not assign the value !
});
刀片輸入:
<div class="col-sm-2 col-md-2">{!! Form::text('cost[0]', null ,['class'=>'form-control cost', 'readonly'=>'readonly' ]) !!}</div>
的源代碼刀片產生這樣的容貌:
<div class="col-sm-2 col-md-2"><input class="form-control cost" readonly="readonly" name="cost[0]" type="text" value=""></div>
有什麼錯誤? –
@JilsonThomas沒有錯誤,我只是沒有輸出值「成本」 – Vince
「成本:不會觸發一個均勻的」數量「觸發事件。我只想將「成本」值分配給輸入字段。 – Vince