G'day there,在变量内添加两个输入
我不确定我该如何做到这一点。这里有一些代码来提供一些上下文。
// API dictionary
$(document).ready(function(){
var itemNameTitle = 'Task'
var itemQtyTitle = 'Quantity'
var itemRateTitle = 'Rate <span>($/hr)</span>'
var itemPriceTitle = 'Price <span>($)</span>'
var itemNameInput = '<input type="text" name="item-name-input" value="Mockups">'
var itemQtyInput = '<input type="text" name="item-qty-input" value="1">'
var itemRateInput = '<input type="text" name="item-rate-input" value="35">'
var itemPriceCalc = 128/2
$('#page').load('templates/default.html', function() {
$this = $(this);
$this.html($this.html().replace('%item-name-title%',itemNameTitle));
$this.html($this.html().replace('%item-qty-title%',itemQtyTitle));
$this.html($this.html().replace('%item-rate-title%',itemRateTitle));
$this.html($this.html().replace('%item-price-title%',itemPriceTitle));
$this.html($this.html().replace('%item-name-input%',itemNameInput));
$this.html($this.html().replace('%item-qty-input%',itemQtyInput));
$this.html($this.html().replace('%item-rate-input%',itemRateInput));
$this.html($this.html().replace('%item-price-calc%',itemPriceCalc));
});
});
我希望你能看到我在这里想要做的。基本上我需要itemQtyInput
和itemRateInput
的value
s乘以一起,然后张贴到页面上的div。不幸的是,当我这样做时,它最终会发布'NaN'。
任何人都知道我在做什么错了?
如何ü可以申请师当itemRateInput是一个字符串变量? –
@NitinVarpe请你详细说明一下吗?我是一名jQuery初学者。 –
在你的问题中没有jQuery。这只是普通的Javascript。您将两个变量设置为字符串。 – Barmar