我尝试将参数设置为:
array("item1","item2","item3")
以及:
new array("item1","item2","item3")
以及:
var Labels = new array("item1","item2","item3")
但我似乎无法将数组传递给以下函数:
function BoldLabel(Labels) {
var length = Labels.length;
var element = null;
for (var i = 0; i < length; i++) {
element = Labels[i];
document.getElementById(element).style.fontWeight="bolder";
document.getElementById(element).style.fontSize="13px";
}
}
我不断收到“数组未定义”错误。我确信我在某处看到了这个,但再也找不到这个例子了。问题是我希望能够重用此代码,因此仅传递我想要加粗的项目数组比将代码剪切并粘贴到新函数并单独写入每个标签名称更容易,例如
document.getElementById("new_pricingsubtotal_c").style.fontWeight="bolder";
document.getElementById("new_pricingsubtotal_c").style.fontSize="13px";
document.getElementById("new_pricingsubtotal1_c").style.fontWeight="bolder";
document.getElementById("new_pricingsubtotal1_c").style.fontSize="13px";
document.getElementById("new_lineitemtotal_c").style.fontWeight="bolder";
document.getElementById("new_lineitemtotal_c").style.fontSize="13px";
document.getElementById("new_trucktotalcost_c").style.fontWeight="bolder";
document.getElementById("new_trucktotalcost_c").style.fontSize="13px";
对此的任何帮助将不胜感激!