我想在我的函数中的一个变量上使用fontcolor()函数。起初,我是在一个数字变量上尝试它,并意识到该函数仅适用于字符串变量。我使用toString()类型化变量,但没有运气! PLS help1Javascript fontcolor()函数不起作用
这里就是我想要做:
var totalCost = toString(numberOfBuckets * costOfBucket);
alert(typeof totalCost); //String
alert(totalCost.fontcolor("red")); //Undefined object
通过“未定义的对象”,你得到字符串“未定义”或“[对象未定义]”? –
Object undefined – user3837378
我认为你正在寻找''(numberOfBuckets * costOfBucket).toString()'或'String(numberOfBuckets * costOfBucket)'。 – DutGRIFF