【发布时间】:2013-10-01 13:49:36
【问题描述】:
我想提醒/提示console.log()的内容。
如何提醒/提示 - console.log("I want to eat" + " " + food);?
我试过alert("I want to eat" + " " + food);,但似乎无效。
例如
<script>
var foodDemand = function(food) {
console.log("I want to eat" + " " + food);
};
foodDemand("Fried Chicken");
</script>
如何提醒/提示 - console.log("I want to eat" + " " + food);?
我试过alert("I want to eat" + " " + food);,但似乎无效。
foodDemand("Fried Chicken"); 在控制台中产生:
"I want to eat Fried Chicken"
如何使用prompt(); 或alert(); 获得相同的效果?
【问题讨论】:
-
将
console.log更改为alert或prompt并按预期工作。 -
和你一样...,将
console.log替换为alert,就是这样... -
为了迂腐,我也会稍微改变一下字符串:
alert("I want to eat " + food); -
@Andy 或者只是你的单引号:
alert('I want to eat ' + food);
标签: javascript alert prompt console.log