我的index.html
<div id="dropDownBolumDiv" class="dropdown-menu" x-placement="bottom-start" style="position: absolute; transform: translate3d(0px, 38px, 0px); top: 0px; left: 0px; will-change: transform;">
</div>
<script>
var parameterYil = document.getElementById("dropDownYil1").value;
var bolumler = ["ELEME MAKİNALARI", "ELEVATÖR", "EXCELL", "FOTOSORTER"];
for (i = 0; i < bolumler.length; i++) {
$("#dropDownBolumDiv").append("<a class='dropdown-item' onclick='refreshCharts(parameterYil,"+bolumler[i]+")'>" + bolumler[i] + "</a>");
}
</script>
例如:当我单击EXCELL时,什么也没有发生。
未被捕获的ReferenceError:未在HTMLAnchorElement.onclick上定义EXCELL
有什么问题?
将Bolumler的单位包装在单引号(')中以使其成为字符串,而不是标识符
bolumler.forEach(v => {
$("#dropDownBolumDiv").append(`<a class='dropdown-item' onclick='refreshCharts(parameterYil,"${v}")'>${v}</a>`);
})
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句