So basically what I need to do, is when I click on one UL list item, while holding Ctrl it needs to duplicate and that copy needs to go to another list, so far I've got to where only when I click on something it goes to another list with no Ctrl which is also mandatory for this homework. I'll upload script what I have so far:
var usersA = document.getElementById("users-a");
var usersB = document.getElementById("users-b");
var onclickA;
var onclickB = function() {
usersA.appendChild(this);
this.onclick = onclickA;
return false;
};
onclickA = function() {
usersB.appendChild(this);
this.onclick = onclickB;
return false;
};
for (var i=0; i < usersA.getElementsByTagName("li").length; i++)
usersA.getElementsByTagName("li")[i].onclick = onclickA;
for (var i=0; i < usersB.getElementsByTagName("li").length; i++)
usersB.getElementsByTagName("li")[i].onclick = onclickB;
Any suggestions on how to do it with the least amount of code as possible? I mean do I need to create another event for that, I am lost, Thanks for any help!