1
我有多个表,并有一个选项下拉菜单循环浏览它们。当我在http://codepen.io/fernandob/pen/JEJRMW中测试代码时,它一切正常,但在Wordpress页面中添加它时,它不会运行。在wordpress中,我使用视觉作曲家,并在文本块中,通过文本编辑器粘贴HTML代码,在此之后。WordPress中的嵌入式Javascript
<script>
if (typeof suffixes !== "undefined") {
suffixes += ",1390152632";
} else {
suffixes = "1390152632";
}
function changeCurrency_1390152632() {
var idx = document.getElementById("id_selected_currency_1390152632").options.selectedIndex;
var currency = document.getElementById("id_selected_currency_1390152632").options[document.getElementById("id_selected_currency_1390152632").options.selectedIndex].value;
var currencies = ["EUR", "USD", "GBP"];
var i, j;
for (i = 0; i < 3; i++) {
var els = document.getElementsByClassName("currency_" + currencies[i]);
var cnt = els.length;
if (currency == currencies[i]) {
for (j = 0; j < cnt; j++) {
els[j].style.display = "block";
}
var a = suffixes.split(",");
for (j = 0; j < a.length; j++) {
document.getElementById("id_selected_currency_" + a[j]).options.selectedIndex = idx;
}
} else {
for (j = 0; j < cnt; j++) {
els[j].style.display = "none";
}
}
}
}
</script>
您是否检查了控制台的错误? –
hi @ hopkins-matt是的,我相信我找到了答案,由于某种原因,它没有读取括号,在源代码中,它取代它的HTML代码 –