Javascript java脚本中的方法和调用多个方法
为什么我不能从custom中调用changeBackground()和toNormal()作为方法 当我将toNormal作为一个方法删除,并将其作为一个独立函数放在custom之外时,代码可以工作,但在custom中却不能 一个对象可以容纳多个方法吗 var自定义= { changeBackground:函数(){ var text=document.getElementById(“para”).style.backgroundColor=“红色”; } toNormal:function(){ var text=document.getElementById(“para”).style.backgroundColor=“”; } } 这是一些文本Javascript java脚本中的方法和调用多个方法,javascript,Javascript,为什么我不能从custom中调用changeBackground()和toNormal()作为方法 当我将toNormal作为一个方法删除,并将其作为一个独立函数放在custom之外时,代码可以工作,但在custom中却不能 一个对象可以容纳多个方法吗 var自定义= { changeBackground:函数(){ var text=document.getElementById(“para”).style.backgroundColor=“红色”; } toNormal:function()
在您的
更改背景
功能之后,您忘记了,
。对象列表需要用逗号分隔
var自定义={
changeBackground:函数(){
var text=document.getElementById(“para”).style.backgroundColor=“红色”;
},//请正确格式化您的代码,您将看到,缺少逗号。请在您的英文文本中更加精确…“as method from custom”-自定义什么?香蕉、苹果、函数、对象???检查此项。
this is some text