[英]Function not outputting code from array into div correctly
我正在尝试使用以下脚本将名称输出到列表中:
var names = ["JakeP97", "Trishy", "Puffs", "Evilgenious", "Joeyc", "TheKid"];
var ballots = ["#book1", "#book2", "#book3", "#book4", "#book5", "#book6"];
function splitName(plName,ballotNum) {
var halfplName = Math.round(plName.length / 2);
var firstplName = plName.substr(0, halfplName);
var lastplName = plName.substr(halfplName, plName.length);
$(ballotNum + 'ul.hardcover_front').find('li:nth-child(2)').html(firstplName);
$(ballotNum + 'ul.hardcover_back').find('li:nth-child(1)').html(lastplName);
}
for (i=0; i<ballots.length; i++) {
splitName(names[i],ballots[i]);
}
不幸的是,它没有输出代码,并且我没有收到任何语法错误,并且问题一定存在于我未发现的逻辑中。
我在这里摆弄着小提琴,上面有为大家编写的代码。 链接到小提琴
让我知道是否有更多信息可以帮助您。 谢谢
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.