I am trying to put a variable inside a jQuery selector. However I am assuming that I am breaking some form of a syntax rule. Please let me know if you can spot the mistake:
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]);
}
Error takes place on the following lines:
$(ballotNum 'ul.hardcover_front')
The desired result would be:
$('#book1 ul.hardcover_front')
, $('#book2 ul.hardcover_front')
etc, all the way.
Thank you in advance!