Properties 无法读取属性';背景色';未定义的

Properties 无法读取属性';背景色';未定义的,properties,undefined,Properties,Undefined,当下面的函数调用运行时,它返回此错误。 未捕获的TypeError:无法读取的属性'backgroundColor' undefined“我正在尝试更改名为 琼伯伦先生。到目前为止,我已经尽了最大努力 Could anyone tell me why this is happening? clrElementJumbo("cornsilk"); function clrElementJumbo(scolor) { var el = document.getElementsByClassN

当下面的函数调用运行时,它返回此错误。 未捕获的TypeError:无法读取的属性'backgroundColor' undefined“我正在尝试更改名为 琼伯伦先生。到目前为止,我已经尽了最大努力

Could anyone tell me why this is happening?

clrElementJumbo("cornsilk");

function clrElementJumbo(scolor) {
  var el = document.getElementsByClassName("jumbotron");
  el.style.backgroundColor = scolor;
}

尝试替换代码

       var el = document.getElementsByClassName("jumbotron");
有以下几点

       var el=document.getElementsByClassName("jumbotron")[0];

尝试替换代码

       var el = document.getElementsByClassName("jumbotron");
有以下几点

       var el=document.getElementsByClassName("jumbotron")[0];