如何提醒console.log的内容?

时间:2013-10-01 13:49:36

标签: javascript alert prompt console.log

我想提醒/提示console.log()的内容。

如何提醒/提示 - console.log("I want to eat" + " " + food);? 我试过alert("I want to eat" + " " + food);,但似乎没有效果。

e.g。

<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();相同?

2 个答案:

答案 0 :(得分:1)

   its working for me

 <script>
    var foodDemand = function(food) {

      alert(food);

    };

    foodDemand("Fried Chicken");
    </script>

答案 1 :(得分:0)

它应该没有任何问题,我可以使用jsFiddle

进行演示

请注意,您无需单独添加空格,请执行以下操作:

"I want to eat " + food