<script type = "text/javascript">
//Add spaces between menu links
//Placement: Global Header
//Coded by Game
var spaces = "2"; //Edit number of spaces between menu links (1,2 or 3)
var a = document.getElementsByTagName("a");
for (i = 0; i < a.length; i++) {
if (a[i].parentNode.parentNode.className == "menubg" && a[i].innerHTML.match(/Home|new topics|help|search|members|calendar|admin|profile|logout|register|login/i)) {
if (spaces == "1") {
a[i].innerHTML += " ";
}
if (spaces == "2") {
a[i].innerHTML += " ";
}
if (spaces == "3") {
a[i].innerHTML += " ";
}
}
}
</script>
上面的代码是为了让用户在他们的菜单项之间添加空格。它工作正常。但是我怎样才能让它可以添加任意数量的空格,而不是限制为 3 个呢?也许他们会以某种方式将他们的数字添加到 var 'spaces' 中,并且代码会将 乘以那个数字?